views:

917

answers:

2

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_once '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).

A: 

If it worked a few hours ago, chances are you are using an expired session key. You will have to renew it.

Johannes Gorset
The code doesn't use any session key, can you please provide more information about that ?
Soufiane Hassou
Make sure you're logged in to facebook and make sure you're not testing the site from your server but from apps.facebook.com/Your_App. I also suggest try doing one thing at a time first to get it working i.e. possibly just stick to getting the friends list as that is the most simplest thing to do. Then move forward as you've figured out where the issue is.
DMin
+1  A: 

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.

Soufiane Hassou
guess you're right, there is an issue with fb right now.
DMin