-1

I'm using facebook sdk for php to retrive facebook friends list for a selected user

the code i used as below

 <?php
 session_start();
 // added in v4.0.0
 require_once 'autoload.php';
 use Facebook\FacebookSession;
 use Facebook\FacebookRedirectLoginHelper;
 use Facebook\FacebookRequest;
 use Facebook\FacebookResponse;
 use Facebook\FacebookSDKException;
 use Facebook\FacebookRequestException;
 use Facebook\FacebookAuthorizationException;
 use Facebook\GraphObject;
 use Facebook\Entities\AccessToken;
 use Facebook\HttpClients\FacebookCurlHttpClient;
 use Facebook\HttpClients\FacebookHttpable;
 // init app with app id and secret
 FacebookSession::setDefaultApplication(      '1481363705467343','5cdb2c0a08c222dda7bab850eb14f6de' );
 // login helper with redirect_uri
     $helper = new      FacebookRedirectLoginHelper('http://localhost/facebook/fbconfig.php' );
 try {
   $session = $helper->getSessionFromRedirect();
 } catch( FacebookRequestException $ex ) {
   // When Facebook returns an error
 } catch( Exception $ex ) {
   // When validation fails or other local issues
 }
 // see if we have a session
 if ( isset( $session ) ) {
   // graph api request for user data
   $request = new FacebookRequest( $session, 'GET', '/me' );
   $response = $request->execute();
   var_dump($response);
   $request1 = new FacebookRequest( $session, 'GET',      '/me/permissions/user_friends' );
   $response1 = $request1->execute();
   var_dump($response1);

   // get response
   $graphObject = $response->getGraphObject();
        $fbid = $graphObject->getProperty('id');              // To Get Facebook ID
        $fbfullname = $graphObject->getProperty('name'); // To Get Facebook full name
         $femail = $graphObject->getProperty('email');    // To Get Facebook email ID
/* ---- Session Variables -----*/
        $_SESSION['FBID'] = $fbid;           
         $_SESSION['FULLNAME'] = $fbfullname;
        $_SESSION['EMAIL'] =  $femail;
     /* ---- header location after session ----*/
   //header("Location: index.php");
 } else {
   $loginUrl = $helper->getLoginUrl();
  header("Location: ".$loginUrl);
 }
 ?>

the result i get is null for 'me/friends', but if i use 'me/' I can retrive the selected user details

please anyone suggest a solution

thanks in advance

shanjock46
  • 48
  • 1
  • 6
  • @ Igy thanks for your time and I tried the above link first only, but i could not get any solution. Can you suggest me any other solutions – shanjock46 Apr 01 '15 at 05:33

1 Answers1

1

See

The /me/friends endpoint no longer includes the full list of a person's friends. Instead, it now returns the list of that person's friends who are also using your app.

Tobi
  • 31,405
  • 8
  • 58
  • 90
  • thank for your answer, but i'm new to facebook php sdk can you please help me out to get full friend's list of a specified person. – shanjock46 Apr 01 '15 at 05:35
  • What part of *...no longer includes the full list of a person's friends. Instead, it now returns the list of that person's friends who are also using your app* you do not understand? **It's no longer possible!** – Tobi Apr 01 '15 at 07:18