我正在实施 facebook 连接,它对我来说部分工作得很好。当某些人使用 facebook 登录时,它成功地登录了用户。这是登录链接http://beta-demo.info/party/users/loginByFacebook但登录后,当我尝试从 Facebook 获取用户详细信息时,它现在显示任何内容。
这是 Fb_Connect.php 的代码 这个文件放在 Libraries 文件夹中
<?php
include(APPPATH.'libraries/facebook/facebook.php');
class Fb_connect extends Facebook{
//declare public variables
public $user = NULL;
public $user_id = FALSE;
public $fb = FALSE;
public $fbSession = FALSE;
public $appkey = 0;
//constructor method.
public function __construct()
{
$CI = & get_instance();
$CI->config->load("facebook",TRUE);
$config = $CI->config->item('facebook');
parent::__construct($config);
$this->user_id = $this->getUser(); // New code
$me = null;
if ($this->user_id) {
try {
$me = $this->api('/me');
$this->user = $me;
} catch (FacebookApiException $e) {
error_log($e);
}
}
}
} // end class
这是记录功能
function loginByFacebook(){
$this->load->library('fb_connect');
$param['redirect_uri']=base_url();
redirect($this->fb_connect->getLoginUrl($param));
}
这是我试图获取值的信息函数。
function facebook() {
print('<pre>');
print_r($this->fb_connect);
if (!$this->fb_connect->user_id) {
echo 'No working ';
//Handle not logged in,
} else {
echo $fb_uid = $this->fb_connect->user_id;
echo $fb_usr = $this->fb_connect->user;
//Hanlde user logged in, you can update your session with the available data
//print_r($fb_usr) will help to see what is returned
}
}
信息页面的 URL http://beta-demo.info/party/users/facebook
我对 facebook 连接 API 不太了解。所以请帮助我