[英]FB.api name undefined
我正在使用Facebook Connect為我的網站開發一個新的Facebook App。 我正在使用JS SDK,並嘗試顯示用戶名。 這是我的代碼:
window.fbAsyncInit = function() {
FB.init({
appId : 'myappid', // App ID
oauth : 'true',
channelUrl : '//mychannelfile', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.login', function (response) {
// do something with response
});
var connecter=false;
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
connecter=true;
FB.api('/me', function(user) {
console.log(user.name);
});
}
else connecter=false;
});
};
如果我檢查控制台,則在連接用戶時user.name的結果是不確定的。 我不明白我在做什么錯。
謝謝您的幫助 !
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '176854392480453',
status : true,
xfbml : true
});
// Additional initialization code such as adding Event Listeners goes here
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
alert("connected");
connecter=true;
FB.api('/me', function(user) {
alert(user.name);
alert(user.first_name);
alert(user.last_name);
alert(user.email);
});
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.