Facebook hooks up PHP API - friends_get () returns an empty array

A few hours ago I managed to get friends_get()

to return an array of friends, but now I don't know if this is my fault or if something is wrong at the end of facebooks (API problems?).

Anyway, I used the code from my 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 works fine, but I can't get the friends list, and I'm testing with it as well api_client->pages_isFan

, and it doesn't seem to work either (says the user is not a fan).

+2


a source to share


2 answers


Facebook seems to be in trouble due to migration.

For reference: http://forum.developers.facebook.com/viewtopic.php?id=56839



Currently the best solution is to use the Open Graph Api .

+3


a source


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



0


a source







All Articles