2011-12-20 155 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的連接工作正常。