- 首先加载并初始化 Facebook JavaScript SDK:https ://developers.facebook.com/docs/reference/javascript/
(加载部分)
仅在 JS SDK 初始化时才应与 FB api 交互。这是一个关闭电话的示例:
FB.api(100000109274242+'/picture',function(userImage){
alert(userImage);
});
UPD
完整示例。HTML:
<div id="fb-root">
<!-- you must include this div for the JS SDK to load properly -->
</div>
<script>
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
});
FB.api(100000109274242+'/picture',function(userImage){
alert(userImage);
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>