gpt4 book ai didi

javascript - 必须使用事件访问 token 来查询有关当前用户的信息

转载 作者:可可西里 更新时间:2023-11-01 02:38:30 26 4
gpt4 key购买 nike

我正在尝试将我的 Facebook 提要输出到 div 元素。

使用这段代码:

<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP ID HERE',
xfbml : true,
version : 'v2.1'
});

FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
console.log('Logged in.');
}
else {
console.log('initiate FB login...');
FB.login();
}
});


FB.api('/me/feed',function(response){
var idDiv=document.getElementById('result');
idDiv.textContent=JSON.stringify(response);
});


};

(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_US/sdk.js";
console.log(js.length);
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


</script>
<div id='result'></div>

我在控制台上显示“已登录”,所以我知道 FB.getLoginStatus() 已返回 connected

div 元素填充了以下错误:

{"error":{"message":"An active access token must be used to query information
about the current user.","type":"OAuthException","code":2500}}

如果 FB.getLoginStatus() 返回 connected,是否应该有一个事件的访问 token ?

最佳答案

在向“我/供稿”发送请求时,您可能没有访问 token 。

getLoginStatus 不仅检查用户是否被授权,它还刷新用户 session 。这就是为什么在“连接”后进行 api 调用很重要的原因。

尝试将对 FB.api 的调用放在 getLoginStatus 中。

这个问题与您遇到的问题类似:Facebook javascript sdk An active access token must be used to query information about the current user

关于javascript - 必须使用事件访问 token 来查询有关当前用户的信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26709869/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com