2013-12-23 57 views
0

我在這裏遇到過幾個問題,他們提出了同樣的問題,但他們現在可能已經過時了。通過電子郵件地址搜索用戶?

我只是試圖查詢圖形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 
    } 
} 

這難道不是支持了?如果我只是搜索一個名稱而不是電子郵件,它的工作正常。

回答

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. 

它似乎返回少得多的結果比圖搜索會,但它適用於很多人,假設他們的隱私設置不會拍成一路上漲。

相關問題