Facebook connect PHP API - friends_get() returns empty array

Posted by Soufiane Hassou on Stack Overflow See other posts from Stack Overflow or by Soufiane Hassou
Published on 2010-05-03T01:11:59Z Indexed on 2010/05/03 1:18 UTC
Read the original article Hit count: 434

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

© Stack Overflow or respective owner

Related posts about facebook

Related posts about facebook-connect