我已登录, 我有访问令牌。 我有app的授权。
我想检索正在使用此应用(特定)应用的用户的朋友。 如果我在浏览器中使用fql和access_token运行URL,那么这会给我准确的结果..但是当使用php代码运行时...没有结果得到..
$userFrndAppUser = null;
$c2 = curl_init();
curl_setopt($c2, CURLOPT_URL, "https://graph.facebook.com/fql?q=SELECT uid,name, is_app_user FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1&access_token=".$access_token);
curl_setopt($c2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c2, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c2, CURLOPT_SSL_VERIFYHOST, false);
$userFrndAppUser = json_decode(curl_exec($c2));
curl_close($c2);
$userFrndAppUser = object2Array($userFrndAppUser);
echo "<br>User's friend which are using this app..";
print_r($userFrndAppUser);
function object2Array($d){
if (is_object($d)){
$d = get_object_vars($d);
}
if (is_array($d))
{
return array_map(__FUNCTION__, $d);
}
else
{
return $d;
}
}
答案 0 :(得分:1)
As per my comment above:
$fql = urlencode('SELECT uid,name, is_app_user FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1');
curl_setopt($c2, CURLOPT_URL, "https://graph.facebook.com/fql?q=".$fql."&access_token=".$access_token);
或者,请查看使用Facebook php sdk获取此https://developers.facebook.com/docs/reference/php/