Facebook getinfo隶属关系只能检索大学?

时间:2012-07-06 14:36:19

标签: php facebook-graph-api facebook-fql

我试图使用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/

有什么建议吗?

1 个答案:

答案 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'];
}