我是新來的Facebook的Javascript SDK時間。我正嘗試使用此API創建應用程序。但是在使用FB.api方法時運氣不佳。不知何故,我的FB.API方法每次都不能正常工作。有時它會給出響應(我只是訪問response.name),而其他時候它不會正確調用。FB.api不工作的每
window.fbAsyncInit = function() {
FB.init({
appId : 'my_app_id', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
FB.getLoginStatus(function(response) {
if (response.authResponse) {
alert('user is:'+response.status);
userId = response.authResponse.userID;
FB.api('/me',function(response) {
alert('Inside FB.api function');
document.getElementById("userInfo").innerHTML = 'Welcome <img src="https://graph.facebook.com/'+ response.id + '/picture" style="margin-right:5px"/>' +response.name + '!';
});
}
});
};
其他方法FB.ui和FB.getLoginStatus和Facebook類似按鈕按預期工作,但只有FB.api不工作無縫的方式等。不要爲什麼?請幫助我確定問題。
:/請格式化後以這樣的方式,人們可以輕鬆地閱讀它... – Lix
當你調用'FB.api(「/我」)'你得到了什麼錯誤? – Lix