Facebook connect PHP API - friends_get() returns empty array
Couple of hours ago I succeed to get friends_get()
to return an array of friends, but, now I don't know if it is my fault or something is wrong in facebooks' end (API problems?).
Anyway I used a code from their documentation:
<?php
require_开发者_如何学Pythononce 'facebook-platform/php/facebook.php';
$appapikey = ''; //CHANGE THIS
$appsecret = ''; //CHANGE THIS
$facebook = new Facebook($appapikey, $appsecret);
//$user_id = $facebook->require_login();
$fb_user=$facebook->get_loggedin_user();
//$fb_user = $facebook->user;
$friends = $facebook->api_client->friends_get();
$friends = array_slice($friends, 0, 10);
$i=0;
foreach ($friends as $friend)
{
$personArray = $facebook->api_client->users_getInfo($friend,"name");
$person[$i]=$personArray[0];
$i++;
}
$i=0;
foreach ($person as $f)
{
echo " ".$f['name'];
//MORE DETAILS HERE IN STEP 2
echo "<br />";
$i++;
}
echo "<br />";
?>
The login is working great, but, I can't retrieve the list of friends and I test also with api_client->pages_isFan
and it doesn't seem to work too (says not a fan while the user is).
It seems that Facebook are having problems due to a migration.
For reference: http://forum.developers.facebook.com/viewtopic.php?id=56839
For now, the best solution is to use the Open Graph Api.
If it worked a few hours ago, chances are you are using an expired session key. You will have to renew it.
精彩评论