facebook在CodeIgniter中连接php sdk问题

时间:2012-08-06 22:10:52

标签: php facebook codeigniter-2

我遇到了facebook connect php库的问题。基本上在返回URL我的用户是0.这是我的代码:

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;
}

$ user在返回网址上始终为0。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

转到config/config.php并替换;

$config['enable_query_strings'] = False;

$config['enable_query_strings'] = TRUE;

刷新并查看魔力
希望它有所帮助!