2011-12-20 98 views
3

我正在使用webtechnick facebook插件,我已经设置了一切,它的FB登录功能完美无缺。webtechnick Facebook登出无法正常工作

我使用$fbc =$this->Connect->User();获取的用户

登录FB细节和分别以

<?php 
    echo $facebook->login(array('perms' => 'email,publish_stream','size'=>'small')); 
?> 

<?php 
    echo $this->Facebook->logout(); 
?> 

进行登录,注销。我在登录后获取用户的详细信息,但在执行注销()后不会取消设置。

我正在使用webtechnick fb插件版本3.1.1。请帮我

回答

2

我的帮助没有太大的帮助,因为我还没有真正找到解决方案。好消息是,你并不孤单:

https://github.com/webtechnick/CakePHP-Facebook-Plugin/issues/43

我可以告诉你的是,Facebook的饼干(fbsr_ {facebook_app_id})或者未删除或正在被重建,这是的根源问题。

编辑

我可能已经发现了什么是怎么回事。直到另外一个晚上,我还没有费心设置我的.htaccess文件,http:/www.example.com和http:/example.com都是有效的。

在我的Facebook应用程序中,我将example.com设置为域,并将网站URL指向www.example.com。

有了fbsr_ {app id} cookie,我注意到它有时在http://example.com上,而我的cakephp cookies在www上。

我在改变我的Facebook应用程序中的URL(添加www,删除www),然后开始在.htaccess中添加或删除www的重写规则。我刚刚从我的Facebook应用程序中删除了appdomain,强制www。到领域,现在一切都是犹太教。

因此,我认为,关键是要

  1. 通过的.htaccess

这确保WWW的

  • 修复标准化不必在Facebook应用程序的应用程序域,无论是CakePHP的和Facebook cookie正被保存到相同的域名,并且当您注销时,它们将从该域名中删除。

    希望这是有道理...

  • 1

    我知道这已经太晚了一些建议,为这个职位。仍然觉得这可能会帮助稍后阅读这篇文章的人。

    我也在面对插件的注销问题,我在插件的ConnectComponent中修改了一个函数来清除会话详细信息,如果操作是“注销”。下面是修改后的功能:

    private function __syncFacebookUser(){ 
    
         if($this->Controller->params['action'] == 'logout') 
          { 
           $this->Controller->Session->delete('FB'); 
           $this->uid = null; 
           $this->Controller->Session->delete('Auth.User'); 
          } 
          else 
          { 
          if(!isset($this->Controller->Auth)){ 
          return false; 
         } 
    
         $Auth = $this->Controller->Auth; 
         if (!$this->__initUserModel()) { 
          return false; 
         } 
         // if you don't have a facebook_id field in your user table, throw an error 
         if(!$this->User->hasField('facebook_id')){ 
          $this->__error("Facebook.Connect handleFacebookUser Error. facebook_id not found in {$Auth->userModel} table."); 
          return false; 
         } 
    
         // check if the user already has an account 
         // User is logged in but doesn't have a 
         if($Auth->user('id')){ 
          $this->hasAccount = true; 
          $this->User->id = $Auth->user($this->User->primaryKey); 
          if (!$this->User->field('facebook_id')) { 
           $this->User->saveField('facebook_id', $this->uid); 
          } 
          return true; 
         } 
         else { 
          // attempt to find the user by their facebook id 
          $this->authUser = $this->User->findByFacebookId($this->uid); 
          //if we have a user, set hasAccount 
          if(!empty($this->authUser)){ 
           $this->hasAccount = true; 
          } 
          //create the user if we don't have one 
          elseif(empty($this->authUser) && $this->createUser) { 
           $this->authUser[$this->User->alias]['facebook_id'] = $this->uid; 
           $this->authUser[$this->User->alias][$this->modelFields['password']] = $Auth->password(FacebookInfo::randPass()); 
           if($this->__runCallback('beforeFacebookSave')){ 
            $this->hasAccount = ($this->User->save($this->authUser, array('validate' => false))); 
           } 
           else { 
            $this->authUser = null; 
           } 
          } 
          //Login user if we have one 
          if($this->authUser){ 
           $this->__runCallback('beforeFacebookLogin', $this->authUser); 
           $Auth->authenticate = array(
            'Form' => array(
             'fields' => array('username' => 'facebook_id', 'password' => $this->modelFields['password']) 
            ) 
           ); 
           if($Auth->login($this->authUser[$this->model])){ 
            $this->__runCallback('afterFacebookLogin'); 
           } 
          } 
          return true; 
         } 
        } 
    } 
    

    对我来说,现在Facebook的插件在Facebook的连接工作正常。