Facebook获取信息隶属关系以检索大学


Facebook getinfo affiliation to retrieve college only?

>im 尝试使用 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/

有什么建议吗?

你在这里使用了一些旧方法。education_history字段已被弃用,具有user.getInfo方法的 RestAPI 也是如此。

一种更面向未来的方法是使用 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'];
}