How to get data from a facebook profile via php SDK

Asked

Viewed 100 times

0

I need to make an application whose goal is to get data from my facebook profile. I need to get for example the name of the photo galleries etc. To simplify I tried to get the name through the php SDK. I got a token through the facebook website and in php it was 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 run this code I get the following error:Graph returned an error: Invalid appsecret_proof provided in the API argument.

Can anyone tell me what’s wrong? What type of token should I generate for this case? I emphasize that the changes and data collection are only from my profile.

  • The error message is the app_secret that he says is invalid, check if it is correct.

  • @Eduardobreno the App secret is valid. I checked it. It’s the secret Proof is not marked as even needed.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.