Reputation: 300
I am trying to use Facebook API for likes on my web page. Currently trying to use all.js
, it fails to load the file at url below as it translates it to file://connect.
//connect.facebook.net/en_US/all.js#xfbml=1
Changing url explicitly to http:
gives a different error.
Do we need APPID for initializing this API and use all.js
or can it be used without APPID?
Reference URL: http://developers.facebook.com/docs/reference/plugins/like/
Upvotes: 0
Views: 3547
Reputation: 8981
According to this answer, an AppId is required. The tool in the reference URL you listed will insert your AppId in the code it generates.
(function(d, s, id) {
...
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=xxxxxxxx";
...
}(document, 'script', 'facebook-jssdk'));
You are probably getting the file://connect
error because you are testing by opening a local file in your web browser instead of a file served by a real web server. When you don't specify the protocol in a link, the browser will assume it's the same protocol as the current page.
From the Facebook documentation:
Note: The URLs in the code are protocol relative. This lets the browser load the SDK over the same protocol (HTTP or HTTPS) as the containing page, which will prevent "Insecure Content" warnings. Missing http and https in the code is intentional.
Upvotes: 3