我关注http://benmarshall.me/facebook-sdk-php-v4-codeigniter/ 教程。在这里我可以获得登录URL但我无法获得注销网址 任何人都可以告诉我为什么我没有得到这个
这是我的facebook libaray注销功能
public function logout_url() {
$_session = $this->helper->getSessionFromRedirect();
$session = new FacebookSession( $_session->getToken() );
$next_url = 'http://localhost/ci_sdk/index.php/welcome/login';
return $this->helper->getLogoutUrl($session,$next_url);
}
这是我在facebook库中的构造函数
public function __construct() {
$this->ci =& get_instance();
$this->permissions = $this->ci->config->item('permissions', 'facebook');
FacebookSession::setDefaultApplication( $this->ci->config->item('api_id', 'facebook'), $this->ci->config->item('app_secret', 'facebook') );
$this->helper = new FacebookRedirectLoginHelper( $this->ci->config->item('redirect_url', 'facebook') );
if ( $this->ci->session->userdata('fb_token') ) {
$this->session = new FacebookSession( $this->ci->session->userdata('fb_token') );
try {
if ( ! $this->session->validate() ) {
$this->session = null;
}
} catch ( Exception $e ) {
// Catch any exceptions
$this->session = null;
}
} else {
try {
$this->session = $this->helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
} catch( Exception $ex ) {
}
}
if ( $this->session ) {
$this->ci->session->set_userdata( 'fb_token', $this->session->getToken() );
$this->session = new FacebookSession( $this->session->getToken() );
$this->logoutURL = $this->helper->getLogoutUrl( $this->session, 'http://localhost/ci_sdk/index.php/welcome/login' );
}
}
这是我的控制器功能
public function logout()
{
$this->load->library('facebook');
$logout_url = $this->facebook->logout_url();
echo '<a href="' . $logout_url . '">logout</a>';
}
它给了我这个错误
Fatal error: Call to a member function getToken() on null in E:\xammp\htdocs\ci_sdk\application\libraries\facebook\facebook.php
我是CodeIgniter的新手,所以请帮助我。 提前致谢