John_116 0 Newbie Poster

Dear All,
I Made a facebook quize website, i wrote code but i have a problem, I want get my name and one of my friend name. but it didn't work.

<?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( '1891889371027640','20aeb28330d6a60cd8927317db5baf26' );
// login helper with redirect_uri1
    $helper = new FacebookRedirectLoginHelper('http://facebquiz.com/en/good-bad/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 ) ) {

$request = new FacebookRequest($session,'GET', '/me/friends/',array('fields' => 'id,name,picture','limit' => '1'));

$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

        $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: result.php?id=$fbid");
} else {
  $loginUrl = $helper->getLoginUrl();
 header("Location: ".$loginUrl);
}
?>