Is the Facebook 开发者_开发知识库JavaScript SDK something I download and upload to my server? Or is it something I just call from my own JS?
I am looking at their documentation here: http://developers.facebook.com/docs/reference/javascript/
But got confused half way through :)
The Facebook JavaScript SDK is ran on the client's system (aka the web browser). The SDK is hosted at Facebook and you only need to include it with <script src='http://connect.facebook.net/en_US/all.js'></script>
. You don't need to upload it to your server.
You use the SDK from JavaScript client-side.
If it's XFBML that you find confusing: it is translated to HTML and CSS client-side by the JavaScript SDK.
There's no need to upload the JavaScript SDK to your server (unless you want to stick to a particular version). If you want you can just reference the one served by Facebook as you would any other script:
<div id="fb-root"></div>
<script src="http://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
});
</script>
Or you can load it asyncronously:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
精彩评论