0

我有以下代码:

 $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

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

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

4

1 回答 1

0

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

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

于 2012-06-27T15:11:03.783 回答