Facebook Graph API - 版本v2.1及更高版本不推荐使用fql [英] Facebook Graph API - fql is deprecated for versions v2.1 and higher
问题描述
这是我的代码:
public function fetchFriendDetails($ accessToken,$ userId){// echo $ accessToken;出口;
$ curlUrl ='https://graph.facebook.com/fql?access_token='。 $ accessToken。 '& pretty = 0& q = {'。 urlencode('v_1:select uid,name,birthday_date,username,current_location from user where uid in(select uid1 from friend where uid2 = me())order by birthday_date desc')。 };
$ ch = curl_init($ curlUrl);
curl_setopt($ ch,CURLOPT_HEADER,0);
curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1);
$ output = curl_exec($ ch);
curl_close($ ch);
$ intermediate = Util :: convertJsonString($ output,'uid','\,',',');
return Util :: convertJsonString($ intermediate,'id','\,',',');
}
它给我以下输出:
{error:{message:(#12)版本v2.1及更高版本不推荐使用fql,type:OAuthException代码:12}}
我知道它已被弃用 https://developers.facebook.com/docs/apps/changelog ,但任何人都可以帮助我在上述代码中应该更改什么这样它会返回准确的结果?
任何帮助将不胜感激。感谢提前
您需要具体请求2.1以下版本
https://graph.facebook.com/v2.0/fql?access_token=
另外您使用的令牌是通过v2.1应用程序发出的,无论您尝试什么都不会工作。
I know there will be a similar question on stackoverflow but it does not seems to work in my case.
Here is my code :
public function fetchFriendDetails($accessToken, $userId) { // echo $accessToken; exit;
$curlUrl = 'https://graph.facebook.com/fql?access_token=' . $accessToken . '&pretty=0&q={' . urlencode('"v_1":"select uid,name,birthday_date,username,current_location from user where uid in (select uid1 from friend where uid2=me()) order by birthday_date desc"') . '}';
$ch = curl_init($curlUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$intermediate = Util::convertJsonString($output, 'uid', '\,', ',');
return Util::convertJsonString($intermediate, 'id', '\,', ',');
}
It gives me following output :
{"error":{"message":"(#12) fql is deprecated for versions v2.1 and higher","type":"OAuthException","code":12}}
I know it is deprecated https://developers.facebook.com/docs/apps/changelog but can anyone please help me what should I change in my above code so that it will return accurate result ?
Any help will be appreciated. Thanks in advance
You need to specifically request a version below 2.1
https://graph.facebook.com/v2.0/fql?access_token=
Also if the token you are using was issued via a v2.1 application it will not work no matter what you try.
这篇关于Facebook Graph API - 版本v2.1及更高版本不推荐使用fql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!