Facebook使用令牌重定向但用户仍然为null或0
$settings = $this->social_model->get_facebook_settings();
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => $settings[0]['value'],
'secret' => $settings[1]['value'],
));
// GET CURRENT USER
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// CHECKS IF NOT LOGIN
if($user == 0){
$params = array(
'scope' => 'publish_stream,publish_actions,manage_pages,status_update,offline_access',
'redirect_uri' => site_url('admin/social/add_facebook')
);
$loginUrl = $facebook->getLoginUrl($params);
echo "<script> window.location = '$loginUrl';</script>";
}else{
$user_accounts = $facebook->api('/me/accounts');
foreach ($user_accounts['data'] as $key => $value) {
$this->social_model->insert_facebook_page($value['name'],$value['access_token'],$value['id']);
}
}
答案 0 :(得分:0)
我能够解决它。我编辑了类文件并用$ _GET替换$ _REQUEST。添加了CURLOPT_SSL_VERIFYPEER =&gt;假,