0

我真的很难理解这里发生了什么。我可以在 OpenGraph 测试器中很好地获取用户详细信息,或者只是点击 URL https://graph.facebook.com/me?access_token=VALID_TOKEN或使用 file_get_contents,但是在尝试 Codeigniter Facebook 库时出现错误“活动访问令牌必须使用...”,如果我只是尝试 CURL GET,我不会得到任何输出。我知道 access_token 是有效的,为什么他们不工作?总体目标是从 iOS App 获取 access_token,并使用 og.likes 通过 Web 服务器使用它来进行 Like。

我的测试功能:

function me_test(){
    $access_token = "VALID_TOKEN";
    $url = 'https://graph.facebook.com/me?access_token=';
    $url_full = $url.$access_token;

    $result = file_get_contents($url_full);
    echo $result;

    // Try Codeigniter Facebook Library
    try {
        $user = $this->facebook->api('/me?access_token='.$access_token);
    } catch (Exception $e) {
        print_r($e);
    }

    // Codeigniter CURL Library
    $this->load->library('curl');  
    echo $this->curl->simple_get($url_full);
    $info =  $this->curl->info;
    print_r($info);

}
4

1 回答 1

0

我也遇到了这个问题,并找到了获取用户数据的替代方法。你可以试试这个

function me_test(){
    $userId = $this->facebook->getUser(); //This will return the current user id

    // Try Codeigniter Facebook Library
    try {
        $user = $this->facebook->api('/'.$userId);
        //When you pass the userid you dont need to provide access token
    } catch (Exception $e) {
        print_r($e);
    }    
}
于 2012-10-26T15:13:34.980 回答