我正在尝试在我的脸书应用中验证用户身份。我正在使用以下代码:
window.fbAsyncInit = function () {
FB.Event.subscribe('auth.statusChange', fbIsReady);
FB.init({ appId: app_id, channelUrl: channelUrl, status: true, cookie: true, xfbml: true, oauth: true});
FB.Canvas.setAutoGrow();
FB.Canvas.scrollTo(0, 0);
};
(function (d) {
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_GB/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
} (document));
function fbIsReady(res){
fbReady = 1;
var params = {method: "oauth", "scope": 'publish_stream'};
FB.ui(params, isLoggedIn);
}
function isLoggedIn(res){
if(!res || res.status === 'not_authorized' || res.perms != 'publish_stream')
fbIsReady();
else if(res.hasOwnProperty('selected_profiles')){
FB.api('/me', {access_token: FB.getAccessToken()}, checkUserInfo);
}
}
function checkUserInfo(){
console.log(res); // return the error bellow right after the user gives permissions and the expected result after refresh
}
我的问题是,在用户在应用程序中进行身份验证后,未设置Access令牌。我需要刷新页面才能工作。我认为在用户认证后我可以执行FB.api('/ me'...)但我得到:
代码:2500消息:“必须使用活动访问令牌进行查询 有关当前用户的信息。“type:”OAuthException“
直到我刷新页面。有什么想法??
由于