我真的很难理解这里发生的事情。我可以在OpenGraph测试人员中获得用户详细信息,或只是访问URL https://graph.facebook.com/me?access_token=VALID_TOKEN或使用file_get_contents,但在尝试Codeigniter Facebook库时,我收到错误“必须使用活动访问令牌......” 如果我只是尝试一下CURL GET,我就没有输出。我知道access_token是有效的,为什么它们不工作?总体目标是从iOS应用程序获取access_token并使用它通过使用og.likes的Web服务器进行类似。
我的测试功能:
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);
}
答案 0 :(得分:0)
我也遇到过这个问题,并找到获取userdata的替代方法。你可以试试这个
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);
}
}