cannot get access token in facebook api 5

时间:2016-04-04 17:52:46

标签: laravel facebook-php-sdk

I cannot get a facebook access token from the following code. I am using laravel4, and with this code I can successfully log in from facebook.

$fb = new Facebook\Facebook(['app_id'=> Config::get('facebook.app_id'),
      'app_secret' => Config::get('facebook.app_secret'),
      'default_graph_version' => 'v2.5',
      ]);
 $this->helper  = $fb->getRedirectLoginHelper();
$accessToken = $helper->getAccessToken();

$accessToken returns null, any idea why?

1 个答案:

答案 0 :(得分:0)

这不是获取你应该返回重定向到的令牌的方法 $ fb-> getRedirectLoginHelper() - > getRedirecturl()并在验证后返回时应使用auth代码生成令牌。如果你不太了解oauth登录流程如何工作,我会建议你使用laravel / socialite包。

很容易处理所有社交登录。 https://laravel.com/docs/5.0/authentication#social-authentication

相关问题