2012-08-06 66 views
0

我遇到了facebook連接php庫的問題。基本上,在返回的網址我的用戶是0。這裏是我的代碼:facebook連接在CodeIgniter中的PHP sdk問題

public function facebook_login() 
{ 
    $params = array(
     'appId' => 'XXXX', 
     'secret' => 'XXXX', 
     'cookie' => TRUE 
    ); 
    $facebook = $this->load->library('facebook', $params); 

    $user = $facebook->getUser(); 

    if (empty($user)) 
    { 
     $url = $facebook->getLoginUrl(array(
      "redirect_uri" => site_url('/auth/facebook/connect') 
       )); 
     header("Location: $url"); 
     exit; 
    } 
} 

public function facebook_connect() 
{ 
    $params = array(
     'appId' => 'XXXX', 
     'secret' => 'XXXX', 
     'cookie' => TRUE 
    ); 
    $facebook = $this->load->library('facebook', $params); 

    $user = $facebook->getUser(); 

    print_r($user);die; 
} 

$用戶永遠是0的返回URL。我怎樣才能解決這個問題?

回答

0

轉到config/config.php並更換;

$config['enable_query_strings'] = False; 

$config['enable_query_strings'] = TRUE; 

刷新,看到了魔術
希望它能幫助!