按电子邮件地址搜索用户



我在这里遇到了一些问题,这些问题提出了同样的事情,但它们现在可能已经过时了。

我只是尝试查询图形 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
   }
}

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

不幸的是,

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

带有电子邮件地址的Facebook搜索API不起作用?

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

$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.

它返回的结果似乎比图形搜索少得多,但它适用于很多人,假设他们的隐私设置没有一路上升。

最新更新