我使用Facebook,Twitter,Google和LinkedIn制作了一个用于社交网络身份验证的CakePHP插件。整个插件100%工作,没有错误或错误,但最近我尝试通过Facebook登录,我发现自己无法从API获取数据。
这就是我所做的。
AuthController Facebook行动
public function facebook(){
$facebookObj = SocialAuth::init('facebook');
$facebookLoginUrl = $facebookObj->getLoginUrl(array('scope' => SocialAuth::getConfig('facebook','permissions'),
'canvas' => 1,
'fbconnect' => 0,
'redirect_uri' => SocialAuth::getConfig('facebook','redirect_uri')));
$this->redirect($facebookLoginUrl);
}
AuthController回调操作
public function callback(){
$facebookObj = SocialAuth::init('facebook');
$facebookInfo = $facebookObj->getUser();
if ($facebookInfo) { // $facebookInfo always return 0 (it was working before >_<)
// ..
}
}
$ facebookInfo 调试信息
/app/Plugin/SocialAuth/Controller/AuthsController.php (line 104)
object(Facebook) {
[protected] sharedSessionID => null
[protected] kSupportedKeys => array(
(int) 0 => 'state',
(int) 1 => 'code',
(int) 2 => 'access_token',
(int) 3 => 'user_id'
)
[protected] DROP_QUERY_PARAMS => array(
(int) 0 => 'code',
(int) 1 => 'state',
(int) 2 => 'signed_request'
)
[protected] appId => '503845519711145'
[protected] appSecret => '--secret--'
[protected] user => (int) 0
[protected] signedRequest => null
[protected] state => '59e2aba0d18dcc166d8c4aef0f1668c9'
[protected] accessToken => '{app-id}|{app-secret}'
[protected] fileUploadSupport => false
[protected] trustForwarded => false
[protected] allowSignedRequest => false
}
如何解决此问题?