我试图使用facebook的api命令users.getInfo
来检索用户(如果存在的)大学。这是我到目前为止所得到的。这不对,但我相信我很接近:
$uid = $facebook->getUser();
$college = $facebook->api_client->users_getInfo($uid, user_education_history [type="college");
供参考,请参阅:https://developers.facebook.com/docs/reference/api/user/
有什么建议吗?
答案 0 :(得分:0)
你在这里使用一些旧方法。已弃用education_history
字段,而使用user.getInfo
方法的RestAPI已弃用。{/ p>
更加面向未来的方法是使用FQL:
$fql = 'SELECT education FROM user WHERE uid = me()';
$ret_obj = $facebook->api(array(
'method' => 'fql.query',
'query' => $fql,
));
$schools = $ret_obj['data']['education'];
$colleges = array();
foreach ($schools as $s) {
if ('College' == $s['type'])
$colleges[] = $s['school']['name'];
}