facebook扩展访问令牌登录

时间:2012-06-27 14:46:48

标签: php facebook

我有以下代码:

 $facebook = new Facebook(array(
                'appId'  => ID,
                'secret' => SECRET,
                'cookie' => true));


   $fb_uid = $facebook->getUser();


   if($fb_uid)
   {
   // check if person with fb_uid as facebook id in database, 
   // if so log them in. If not, register them.


    $fb_user = $facebook->api('/' . $fb_uid);


     I then get their email address using $fb_user['email'] and facebook_id and store in the database as a means to log them in the future

有时$ fb_uid会返回false,即使此人使用Facebook登录...我认为这是因为访问令牌过期了。如何更改此代码以合并扩展访问令牌以将用户登录到我的站点?

不推荐使用

离线访问令牌,因此我需要使用扩展访问令牌。

1 个答案:

答案 0 :(得分:0)

您的Cookie即将过期。不使用cookie和屏幕抓取,而是使用OAuth。

请参阅此处的示例:http://eggie5.com/20-getting-started-w-facebook-api