Facebook我正在使用 facebook javascript sdk 登录用户,然后我希望通过 php sdk 获取他的一些信息,但我不断收到“必须使用活动访问令牌来查询有关当前用户的信息”。
这是相关的 html/js 代码:
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '8', // App ID from the app dashboard
channelUrl : '//url/frontend/channel.php', // Channel file for x-domain comms
status : true, // Check Facebook Login status
cookie : true,
oauth:true,
xfbml : true // Look for social plugins on the page
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
submitform();
} });
};
function submitform() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me?fields=email,name', function(response) {
//submits a form from this page...
});
}
</script>
<a href="javascript:FB.login()" class="facebook-login">Facebook</a>
失败的php是:
$facebook = new Facebook(array(
'appId' => Configuration::$facebook_app_id,
'secret' => Configuration::$facebook_app_secret));
// Get User ID
$user_profile = $facebook->api('/me?fields=name,id','GET');
它似乎工作了一段时间,然后它打破了
" [message] => An active access token must be used to query information about the current user.
[type] => OAuthException
[code] => 2500",
任何人都知道如何稳定这一点?
谢谢