简体   繁体   English

Facebook PHP Sdk访问令牌

[英]Facebook PHP Sdk Access Token

I know there are tons of topics 我知道有很多话题

on this question, but every single one that I've seen, seems to have no solution at all! 关于这个问题,但是我见过的每一个似乎都根本没有解决方案! I'm getting the infamous "Oauth Exception - An active access token must be used to query information about the current user" and I don't know what to do. 我收到了臭名昭著的“ Oauth异常-必须使用活动访问令牌来查询有关当前用户的信息”,但我不知道该怎么办。

My facebook connect was working perfectly fine until yesterday, now, it stopped working all of a sudden today. 直到昨天,我的facebook connect都运行良好,现在,今天突然停止了工作。

Can anyone please help me with this? 谁能帮我这个忙吗? I'm using php sdk to connect the user to facebook in a pop-up window, then I make him autorize my app and redirect the window to a php called facebookReturn.php. 我正在使用php sdk在弹出窗口中将用户连接到facebook,然后让他对我的应用进行自动注册并将该窗口重定向到名为facebookReturn.php的php。 In this file, I'm supposed to get the user info, save it on Session, then close the window and refresh the main page behind. 在这个文件中,我应该获取用户信息,将其保存在Session上,然后关闭窗口并刷新后面的主页。

Here are my codes. 这是我的代码。

index.php: index.php:

require_once 'phps/facebook.php';

$config = array();
$config[appId] = 'xxxx';
$config[secret] = 'xxxx';
$config[fileUpload] = false;
$facebook = new Facebook ($config);

$facebookId = $facebook->getUser();
echo "<br>facebook id: $facebookId";

if ($facebookId) {
    $userProfile = $facebook->api('/me');
    $logoutUrl = $facebook->getLogoutUrl();
}
else {
    $params = array ();
    $params[scope] = 'publish_stream, user_birthday, email, user_activities';
    $params[redirect_uri] = 'http://www.mydomain.com.br/phps/facebookReturn.php';
    $params[display] = 'popup';
    $loginUrl = $facebook->getLoginUrl($params);
}

facebookReturn.php: facebookReturn.php:

require_once 'facebook.php';
$config = array();
$config[appId] = 'xxxx';
$config[secret] = 'xxxx';
$config[fileUpload] = false;
$facebook = new Facebook ($config);

$user = $facebook->getUser();
$userProfile = $facebook->api('/me');

Thank you in advance. 先感谢您。

提醒:Facebook令牌将在60天后过期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM