Getting friends list using facebook api's

只谈情不闲聊 提交于 2019-12-04 15:03:40
ifaour

If you have a valid session, then this should retrieve the current user's friends:

$friends = $facebook->api("/me/friends")

But if you don't have a valid session (or need to retrieve this offline) you need the offline_access permission and your code will also work.
UPDATE:
Since the deprication of the offline_access permission, you need a long-lived access_token.


Please note that you can get the friends list with this FQL query too:

$friends = $facebook->api(array(
    "method"    => "fql.query",
    "query"     => "SELECT uid,name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"
));
Kalim Fleet

This post on SO may provide the answer you are looking for. You will need to get the friends object then do a foreach loop over it to print the results (as described in the post). Read Getting list of Facebook friends with latest API

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