问题
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