Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook graph api 使用FB Graph API获取用户好友数据_Facebook Graph Api_User Permissions - Fatal编程技术网

Facebook graph api 使用FB Graph API获取用户好友数据

Facebook graph api 使用FB Graph API获取用户好友数据,facebook-graph-api,user-permissions,Facebook Graph Api,User Permissions,我正在尝试使用Graph API访问用户朋友的工作和教育历史。我已经在auth对话中包含了这两个权限。我曾尝试使用FQL访问它们,但没有成功 try{ $fql = "select friends_education_history from permissions where uid=" . $user; $param = array( 'method' => 'fql.query',

我正在尝试使用Graph API访问用户朋友的工作和教育历史。我已经在auth对话中包含了这两个权限。我曾尝试使用FQL访问它们,但没有成功

try{
        $fql    =   "select friends_education_history from permissions where uid=" . $user;
        $param  =   array(
            'method'    => 'fql.query',
            'query'     => $fql,
            'callback'  => ''
        );
        $fqlResult   =   $facebook->api($param);
    }
    catch(Exception $o){
        d($o);
    }
}
我更喜欢不使用FQL访问信息,但在这一点上,我需要找出任何方法。有没有办法做到这一点:

 if($user_id) {
  try {
        $friends = $facebook->api("/me/friends");
    }
    catch(Exception $o){
        d($o);
    }
}
?>
SELECT education,work from user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
然后调用相应的变量?

has字段
education
work

第一个需要权限
user\u education\u history
friends\u education\u history
,第二个需要权限
user\u work\u history

这些字段是可选的&用户可以通过其配置文件页面限制其可见性,因此即使授予权限,api也可能不返回任何内容


使用播放。

您的FQL查询如下所示:

 if($user_id) {
  try {
        $friends = $facebook->api("/me/friends");
    }
    catch(Exception $o){
        d($o);
    }
}
?>
SELECT education,work from user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
上述查询将从登录用户的朋友处获取所有教育和工作对象

SELECT education,work from user WHERE uid = <YOUR FRIENDS USER ID>
选择教育,从用户处工作,其中uid=
以上查询将仅针对您提供的一个用户id获得教育和工作


希望这有帮助

多谢各位。很好,现在就走。马特,如果你能把它作为答案,如果它对你有用的话,那就太好了。谢谢,祝你好运!我也有同样的问题。我已经向用户请求了正确的权限,但是如果我从
/me/friends?fields=work,education
切换到
/#user\u id#/friends?fields=work,education
,API不会返回这些字段。