0
我在這裏和網絡上搜索了我的問題,但是我沒有找到任何解決方案,這讓我發瘋,我不知道最新的proplem。 的propble是,的getUser()函數總是返回0Codeigniter用facebook登錄,getUser總是返回0
這裏我的圖書館:
include(APPPATH.'libraries/facebook.php');
class Fbconnect extends Facebook{
public $user_id = null;
public $user = null;
function Fbconnect(){
$ci =& get_instance();
$ci->load->config('facebook',true);
$config = $ci->config->item('facebook');
parent::__construct($config);
$this->user_id = $this->getUser();
$me = null;
if($this->user_id){
try{
$me = $this->api('/me');
$this->user = $me;
}catch(FacebookApiException $e){
error_log($e);
}
}
}
}
,這是控制器
function facebookRequest(){
$this->load->library('fbconnect');
$data = array(
'redirect_uri' => base_url().'home/handleFacebookRequest',
'scope' => 'email'
);
redirect($this->fbconnect->getLoginUrl($data));
}
function handleFacebookRequest(){
$this->load->library('fbconnect');
if($this->fbconnect->user){
echo '<pre>';
print_r($this->fbconnect->user);
}else{
echo "Login operation faild, try again later";
}
}
和我使用的配置文件來存儲應用程序ID和祕密
$config = array(
'appId' => 'xxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxx',
'cookie' => true
);
其中i可以添加這一行'$ opts [CURLOPT_SSL_VERIFYPEER] = false;' –
@MohamedNagy在你插入的代碼中,你有一個'makeRequest'函數是一個捲曲調用。在那裏看到它。你是否嘗試使用錯誤日誌? –
好的,我做到了,當我打印'$ e'時出現異常:'CurlException:7:無法連接到主機' –