通过电子邮件地址搜索用户?

时间:2013-12-23 07:19:17

标签: facebook

我在这里遇到过一些问题同样问题,但现在可能已经过时了。

我只是想查询Graph API以通过电子邮件地址搜索用户。我一直在努力:

https://graph.facebook.com/search?q={EMAIL}&type=user&access_token=***

但是这会返回错误:

{
   "error": {
      "message": "(#200) Must have a valid access_token to access this endpoint",
      "type": "OAuthException",
      "code": 200
   }
}

这不再受支持吗?如果我只是搜索名称而不是电子邮件,那么它可以正常工作。

2 个答案:

答案 0 :(得分:0)

不幸的是,几个月前,这种行为似乎已从Facebook API中删除。以下是11月初的相关问题:

Facebook Search API with email address not working?

答案 1 :(得分:0)

这无论如何都不是一个完美的解决方案,但它可能总比没有好。

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.facebook.com/search.php?q=".rawurlencode($email));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11');
$response = curl_exec($ch);

$response = html_entity_decode($response);
$response = explode(',"id":', $response);
$id = $response[1];
$id = substr($id, 0, strpos($id, ',')); //FB ID of the first person in the results.

它似乎返回的结果远远少于图搜索,但它适用于很多人,假设他们的隐私设置没有被提升。

相关问题