How to get data from a facebook profile through the php SDK

0

I need to make an application whose purpose is to get data from my facebook profile. I need to get for example the name of the photo galleries etc. For simplicity I tried to get the name through the php SDK. I got a token through the facebook website and in php it looked like this:

// Start the session
session_start();


require_once __DIR__ . '/facebook-sdk-v5/autoload.php';
$fb = new Facebook\Facebook([
    'app_id' => '{aqui coloco o id}',
    'app_secret' => '{aqui coloco a chave}',
    'default_graph_version' => 'v2.8',
]);

$fb->setDefaultAccessToken("token gerado");


//print_r($user);

/*  // Sets the default fallback access token so we don't have to pass it to each request
$fb->setDefaultAccessToken('{EAACEdEose0cBAEikRrkW1LpHKKfVKkIsf7flezUh69DDtFV7RwoOZCdkokz6yqQ8X8GUC6OHaK3hhYN8SEZBTdTre6VGrkOKhgoCom5GHdMtCHj0V0SKTfOgZCua0419IkyCscXUuynpCUsCsCogt0HiAssV6yiaWWK7mZCS66QdLCNZAZClfX}');
*/try {
  $response = $fb->get('/me?fields=id,name');
  //$userNode = $response->getGraphUser();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  // When Graph returns an error
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  // When validation fails or other local issues
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}

?>

When I execute this code I get the following error: Graph returned an error: Invalid appsecret_proof provided in the API argument.

Can someone explain what's wrong? What kind of token should I generate for this case? I would like to point out that the changes and obtaining data are just my profile.

    
asked by anonymous 08.11.2016 / 14:30

0 answers