0

I get the error "Graph returned an error: Invalid OAuth access token" even if I set the appId, appSecret, accesstoken correctly. And yes, the token is set in the Facebook Developer page.

<?php
session_start();

require_once ('data/Facebook/autoload.php');

$fb = new Facebook\Facebook([
  'app_id' => 'xxxxxxxxxxx',
  'app_secret' => 'xxxxxxxxxxxx',
  'default_graph_version' => 'v2.5'
]);

try {
  $response = $fb->get('/me','xxxxxxxxxxx');
}
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;
}

$me = $response->getGraphUser();
echo 'Logged in as ' . $me->getName();

?>
Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159
  • 1
    http://stackoverflow.com/questions/4823018/facebook-graph-api-getting-invalid-oauth-access-token-after-3-https-calls – adeneo Dec 19 '15 at 10:42
  • I don't have proper authentication set... uhmm... I said that the appId, appSecret and accessToken are IDENTICAL as the ones in the App Developer Page... What other stuff should match in order to make it work? This is a website, plain facebook PHP oauth2 using a redirect uri.. – Gianluca Ghettini Dec 19 '15 at 10:47
  • It's been a while since I've done this, but you did get the accessToken specifically for the user you're logging in etc – adeneo Dec 19 '15 at 10:53
  • there is no authentication in your code, same answer as in the other thread applies – andyrandy Dec 19 '15 at 11:25

0 Answers0