我在Facebook Graph API中遇到问题。 我想从每个帖子中拍照并将其插入到图库中,所以我提出了很好的查询,我的代码看起来像这样:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '1385526288185078',
status : true,
xfbml : true,
version : 'v2.8'
});
FB.AppEvents.logPageView();
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
});
FB.api(
'/me',
'GET',
{"fields":"posts{picture}"},
function(response) {
console.log(response);
}
); {scope: 'user_posts'};
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.8&appId=1239065502849136";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
在控制台中我收到错误:
错误:对象
代码:2500
fbtrace_id: “Em9cGkfMeHX”
消息:“必须使用活动访问令牌来查询有关当前用户的信息。”
类型: “OAuthException”
而且我很确定我的令牌是有效的!有人可以协助检查或做什么吗?
答案 0 :(得分:1)
您需要授权用户:
FB.login(function(response) {
if (response.authResponse) {
//user just authorized your app
}
}, {scope: 'user_posts'});
来源:https://developers.facebook.com/docs/reference/javascript/FB.login/
示例:http://www.devils-heaven.com/facebook-javascript-sdk-login/