Return list of current Facebook user's friends PHP

时间秒杀一切 提交于 2019-12-01 11:13:45

问题


I am working on a Facebook app that will allows users to vote on their favorite pictures, based on their friend's profiles pictures. I know how to display the images, just not how to get the list of the current user's friend's IDs. My application is written in PHP. This is the last thing I need to complete the app. Any help would be great!


This is my code: (Just to display each user ID on the page)

<?php
include_once 'facebook.php';
$apikey = 'API KEY HERE';
$secretkey = 'SECRET KEY HERE';

$fbObj = new Facebook($apikey, $secretkey);

$myuid = $fbObj->require_login();

$friends = $fbObj->api('$myuid/friends');
echo $friends;
?>

That code raises the following PHP error:

PHP Fatal error:  Call to undefined method Facebook::api() in /home/zach/public_html/Majik/animated.php on line 10

回答1:


If you are able to use Graph - then it is easy

https://graph.facebook.com/me/friends

More details at: http://developers.facebook.com/docs/reference/api/user

After that you can iterate through the users list and use

https://graph.facebook.com/<user_id>/picture

to display user's picture.




回答2:


copy the facebook api file into the same directory you are working from



来源:https://stackoverflow.com/questions/4064974/return-list-of-current-facebook-users-friends-php

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