I have experience with PHP and JavaScript, but am new to using the FaceBook API. I'm carefully reading through the documentation, but notice thta lot of links within their documentation are broken. For example, the link for http://api.facebook.com/static/xd_receiver.htm is broekn and I need that content to be able to do almost anything with the FB API. Seriously, these guys seem to have really dropped the ball with their documentation. Does anyone know where I can get this file and the rest of the JavaScript SDK? Thanks.
<div id="fb-root"></div>
<script src="//connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'YOUR APP ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelUrl : 'http://WWW.MYDOMAIN.COM/channel.html', // channel.html file
oauth : true // enable OAuth 2.0
});
</script>
The contents of the channel.html file should be this single line:
<script src="//connect.facebook.net/en_US/all.js"></script>
You don't necessarily download it yourself so much as load it when you want to use it.
Here's a link to the quickstart
https://developers.facebook.com/docs/javascript/quickstart/v2.0
Here is the documentation that facebook has for their Javascript SDK. There are some areas that are poor (to put it lightly), but most of it is there, or in the comments/forums created by users
Related
I am trying to integrate facebook login with my website. I am following this link:
https://developers.facebook.com/docs/facebook-login/getting-started-web/
There, it says that " Replace YOUR_APP_ID with the app ID noted in Step 1 above and WWW.YOUR_DOMAIN.COM with your own domain. " for the following piece of code:
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
So my question is, what is my domain here? How can i find out what my domain is? Actually, what does this mean? Can anyone help?
Thanks
It simple. You should put or make file with name channel.html to your server. The contents of the channel.html file can be just a single line:
<script src="//connect.facebook.net/en_US/all.js"></script>
After you should replace '//WWW.YOUR_DOMAIN.COM/channel.html' to full path to the file on the server. Here // is meant protocol instead http:// and https://
I want to use the Facebook JS SDK within a browser extension/sidebar. I've seen other questions about this, but no specific answers. I don't want to do separate OAuth handling - I'd prefer to use the JS SDK which makes this all transparent.
However, it seems that the FB.* calls never fire their callbacks at all. Am I missing something? Is it even possible to use the JS SDK within a non-hosted environment?
Example:
window.fbAsyncInit = function() {
FB.init({
appId : 'XXX',
status : true,
cookie : true,
xfbml : false
});
FB.getLoginStatus(function(response) {
alert('CALLBACK');
});
};
Thanks,
Matt Kruse
As stated on this blog post
Unfortunately, Facebook JavaScript SDK doesn’t work on a Chrome
Extension because it is working under “chrome-extension://” protocol.
While Google provides a tutorial for OAuth, Facebook explains a
slightly easier way.
Facebooks OAuth/login explanation
You could try the invisible iFrame technique posted here: http://brianmayer.com/2012/12/building-a-chrome-extension-that-connects-to-a-facebook-app/
But it seems like a lot of work.
I currently have a like button on my app and I need to detect when this is clicked so that I can trigger some javascript.
Currently I use this:
FB.Event.subscribe('edge.create', function(response) {});
In order for this to work you must use the FBML version of the like button. It does not work with the HTML5 version.
I am wondering what the situation will be from Jan 1st when FBML is deprecated?
Thanks
Actually, you can do what you're wanting to do with the HTML5 version. You're Javascript will look something like this:
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// CUSTOM LISTENING CODE, or anything else using FB.something, goes below
// SAMPLE LISTENING CODE
FB.Event.subscribe('edge.create',
function(response) {
alert('You liked the URL: ' + response);
}
);
FB.Event.subscribe('message.send',
function(response) {
alert('You sent the URL: ' + response);
}
);
// END SAMPLE LISTENING CODE
};
Note that you'll also have to set up a channel file, explained in the Facebook Javascript SDK documentation. But having properly initialized the Javascript SDK, and then remembering to include all FB.something code in the window.fbAsyncInit function, you absolutely can detect when the HTML5 like button is pressed.
FBML and xFBML aren't the same thing.
xFBML is used to add buttons easily to web pages.
FBML was a language used to develop canvas apps.
If FBML is deprecated, xFBML isn't planned to be removed !
Please Note: Our deprecation of FBML does not impact XFBML (eXtended Facebook Markup Language). XFBML is a set of XML elements that can be included in your HTML pages to display Social Plugins. When your page is loaded, any XFBML elements found in the document are processed by the JavaScript SDK, resulting in the appropriate plugin being rendered on your page. The JavaScript SDK will continue to support XFBML after the deprecation of FBML (save for the fb:serverFbml element which is used to execute FBML on our servers).
Source : https://developers.facebook.com/blog/post/568/
I have written a Facebook website app that gives the possibility to push reactions that people give to news items to there Facebook wall. Everything works fine except in IE8.
When I visit the homepage with IE9 compatibility mode IE8 I get:
Unable to set value of the property 'innerHTML': object is null or undefined
When visit with authentic IE8 I get:
'root' is null or not an object
This is the Facebook code I have on that page:
<script src="http://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script>
FB.init({
appId : '${siteConfiguration.facebookAppId}',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
I have tried putting the script tags in the and the fb-root in the but I still get the error.
It was right in front of me!
FB quote: The best place to put this code is right before the closing </body> tag.
I placed it in the <head> tag.
Guess you need to reorder your code put the line
afer
so your code now will be
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '${siteConfiguration.facebookAppId}',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
I can't add FB login to my site. I simply registered the application:
URL: http://www.chusmix.com/
DOMAIN: www.chusmix.com
And then I pasted the login code and replaced my APP id in it:
<html>
<head>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'212044715486306', cookie:true,
status:true, xfbml:true
});
</script>
<fb:login-button>Login with Facebook</fb:login-button>
</body>
</html>
However when clicking the login button I get Error 191: redirect_uri is not owned by the application
Also this code is in the page: http://www.chusmix.com/game/ according to what Facebook says filling the field DOMAIN makes all pages in the domain able to use Facebook Authorization. However I also tried pointing directly to the domain where the Login Button is and I get the same error.
There isn't even a redirect url.
Update: It seems the Login works in http://www.chusmix.com/game/ but doesn't on http://chusmix.com/game/ (without www).
Is there a way to make it work if the user doesn't type www.? Or do I have to use a redirect?
Try adding the site URL to the app settings Edit Settings->Web Site->Site URL. While you are there you might as well fill in the Site Domain in case you add sub domains in the future.
Use this as you Site Domain: chusmix.com
Make sure every URL in your JS script matches EXACTLY to the Site URL you set up in Facebook, including http://.
Ex:
FB.init({
appId : '128957350986', // App ID
channelUrl : 'zazzlebaytobreakers.com/lib/channel.php', // Channel File
Will cause this error in IE 7 and 8.
Make sure it's:
FB.init({
appId : '128957350986', // App ID
channelUrl : 'http://zazzlebaytobreakers.com/lib/channel.php', // Channel File