14

I am trying to use the Facebook javascript sdk for my chrome extension. Since it is a chrome extension how do i integrate it with facebook? is it an app on facebook.com or a website?

Currently i have it as a website.

my site url on the settings is: http://localhost/Users/home/Documents/facebook/

i have also enabled web sharing on my mac.

do i need to set the site domain as well? what am i doing wrong here?

bkaid
  • 51,465
  • 22
  • 112
  • 128
Praveen
  • 1,781
  • 6
  • 26
  • 32

4 Answers4

19

Enter http://localhost/Users/home/Documents/facebook/ as your "Site Domain" on the developer app:

https://developers.facebook.com/apps/{api_key}/summary

Replace {api_key} with yours; or find a link at https://developers.facebook.com

Interestingly enough, Facebook lets you type anything into the domain so it can be an offline URL (such as localhost or a local port) and Facebook will redirect to it after authentication.

Mike Knoop
  • 506
  • 2
  • 11
  • If you try this you will get the message: `Error App Domains: http://localhost/Users/home/Documents/facebook/ should not contain protocol information.` – Luis Perez Apr 22 '13 at 23:44
  • 4
    Don't confuse "Site Domain" with "App Domains". To see the "Site Domain" option you have to check "Website with Facebook Login" so that it's green that will reveal the textbox. – Luis Perez Apr 22 '13 at 23:50
  • Thanks for the tips! PS the entire URL needs to be supplied, and not just "localhost". Any idea why? – Nimo Jul 08 '13 at 07:08
6

You can test Facebook applications locally if you add an entry to your hosts file which points to any subdomain of the root domain you gave Facebook. For example, if your domain is example.com, you can add entry to your hosts file pointing fbtest.example.com to localhost (127.0.0.1).

You can then test away locally without having to edit your Facebook app configuration (assuming your local server is set to serve the same content to all subdomains).

Alternatively, if it's important to have the exact domain, you can just add an entry for the root domain. It just means you won't be able to access the live site while testing.

Michael Mior
  • 28,107
  • 9
  • 89
  • 113
  • Works like a charm. And a good answer, because you don't have to mess up your Facebook configuration. – xgretsch Mar 16 '17 at 17:33
3

In order to develop and publish a Facebook application, you must provide a web accessible URL that Facebook can query. If you have webspace you can upload to or make your IP available to the web for Facebook to call, it should solve your problems.

Facebook will allow you to put just about any valid url into the box, however when you go to use it for logins or general use, you will begin to notice errors, since Facebook's spider cannot fetch the url.

Francis Pelland
  • 784
  • 4
  • 11
  • so then can i just upload all my documents to the cloud and then enter the link to the folder on the cloud as a site url?? – Praveen Aug 25 '11 at 03:55
  • Yup, that should work in theory. There are plenty of free places you can upload to try it out. Once Facebook's code can validate it is coming from an authenticated URL, everything should begin to work. – Francis Pelland Aug 25 '11 at 04:01
  • The URL does not have to be web accessible, the domain you are visiting simply has to match. The IP can be totally private on your local network. See my answer. – Michael Mior Aug 25 '11 at 04:19
  • i set a home web server and provided a link to the chrome extension folder. i still get the same error – Praveen Aug 25 '11 at 04:24
  • @Michael : all i am doing is call Fb.init() where the javascript facebook connect sdk is mentioned. – Praveen Aug 25 '11 at 04:27
  • I don't understand your reference to "the chrome extension folder". In any case, you need to access your local machine via a domain which is authorized by Facebook as I mentioned in my answer. – Michael Mior Aug 25 '11 at 04:28
3

Check the 'Desktop Apps' section of https://developers.facebook.com/docs/authentication/ This explains how to do authentication where there's no server involved, it's aimed at desktop apps but a browser toolbar should work in a similar way

Igy
  • 43,710
  • 8
  • 89
  • 115