How to get all Facebook friend`s Id at once?

非 Y 不嫁゛ 提交于 2020-01-04 14:16:08

问题


Earlier when I open graph.facebook.com, I can get the ID's of all the friends of mine at one place but now I am getting redirect to another developer page.

I want to know whether any method still left by which I can get the friend's ID at once. I know that graph.facebook.com/username feature, but I want to have all at once.


回答1:


Here is an example using the facebook-php-sdk that will return the id number for all your friends from within your application:

include_once('facebook-php-sdk/src/facebook.php');

$facebook = new Facebook(array(
  'appId'  => '<your_app_id>',
  'secret' => '<your_app_secret>',
));
$result = $facebook->api("/me/friends?limit=0");
$friends = array();
foreach ($result['data'] as $index => $friend) {
   $friends[] = $friend['id'];
}



回答2:


The path graph.facebook.com/[user id]?fields=friends.fields(id) will get what you want. You just have to make sure to send the appropriate credentials.

I recommend you use Facebook's Graph Explorer tool. It is handy to select what you want.

http://developers.facebook.com/tools/explorer/?method=GET&path=511552816%3Ffields%3Did%2Cname



来源:https://stackoverflow.com/questions/14404089/how-to-get-all-facebook-friends-id-at-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!