我正在尝试将短期用户访问令牌交换为 ling-lived,但出现错误(在 all.js 中):
ReferenceError:左侧分配无效
...TZCOZCkuZBxZAzVUSokiOJbXZAHhESJvuA97qXTpVbVj3P7AZDZD&expires=512326
response.error.message:未知错误
代码:
window.fbAsyncInit = function () {
FB.init({
appId: 'xxx', // App ID
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true, // parse XFBML
oauth: true
});
FB.login(function (response) {
if (response) {
var accessToken = response.authResponse.accessToken;
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var accessToken = response.authResponse.accessToken;
var OauthParams = {};
OauthParams['client_id'] = 'xxx';
OauthParams['client_secret'] = 'xxx';
OauthParams['grant_type'] = 'fb_exchange_token';
OauthParams['fb_exchange_token'] = accessToken;
OauthParams['response_type'] = 'token';
console.log(accessToken);
FB.api('/oauth/access_token', 'post', OauthParams, function(response) {
if (!response || response.error) {
console.log(response.error.message);
}
else {
console.log(response.accesstoken);
}
});
}
});
};
}, { scope: 'manage_pages' });
};
}
(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));
有人有想法吗?
谢谢,/M