P
P
Petr Flaks2015-09-19 22:49:54
PHP
Petr Flaks, 2015-09-19 22:49:54

Why is the Facebook API request not working?

Hello!
I am using Facebook PHP SDK v5 . When this code is executed

require_once __DIR__.'includes/facebook/src/Facebook/autoload.php';
  
$fb = new Facebook\Facebook([
  'app_id' => $fb_app_id,
  'app_secret' => $fb_app_secret
]);

$fb->setDefaultAccessToken($fb_access_token);

echo '<pre>';
print_r($fb->get('/me'));
echo '</pre>';

then the following error is returned:
Fatal error: Uncaught exception 'Facebook\Exceptions\FacebookAuthenticationException' with message 'Invalid appsecret_proof provided in the API argument' in path/includes/facebook/src/Facebook/Exceptions/FacebookResponseException.php:100
Stack trace:
#0 path/includes/ facebook/src/Facebook/FacebookResponse.php(210): Facebook\Exceptions\FacebookResponseException::create(Object(Facebook\FacebookResponse))
#1 path/includes/facebook/src/Facebook/FacebookResponse.php(255): Facebook\ FacebookResponse->makeException()
#2 path/includes/facebook/src/Facebook/FacebookResponse.php(82): Facebook\FacebookResponse->decodeBody()
#3 path/includes/facebook/src/Facebook/FacebookClient.php(225): Facebook\FacebookResponse->__construct(Object(Facebook\FacebookRequest), '{"error":{"mess...', 400, Array )
#4 path /includes/facebook/src/Facebo in path/includes/facebook/src/Facebook/Exceptions/FacebookResponseException.php on line 100

As a variable $fb_access_token I pass an unlimited token made according to this guide , and as variables $fb_app_id and $fb_app_secret - data from the application settings page.
Everything is disabled in the application settings: I googled, of course. I mostly found solutions where it was said that an additional appsecret_proof parameter should be passed . The query string looked like this:
eqpkyHp.png

print_r($fb->get('/me', hash_hmac('sha256', $fb_access_token, $fb_app_secret)));

But in this case, the returned error changes to this:
Fatal error: Uncaught exception 'Facebook\Exceptions\FacebookAuthenticationException' with message 'Invalid OAuth access token.' in path/includes/facebook/src/Facebook/Exceptions/FacebookResponseException.php:100
Stack trace:
#0 path/includes/facebook/src/Facebook/FacebookResponse.php(210): Facebook\Exceptions\FacebookResponseException::create(Object (Facebook\FacebookResponse))
#1 path/includes/facebook/src/Facebook/FacebookResponse.php(255): Facebook\FacebookResponse->makeException()
#2 path/includes/facebook/src/Facebook/FacebookResponse.php(82 ): Facebook\FacebookResponse->decodeBody()
#3 path/includes/facebook/src/Facebook/FacebookClient.php(225): Facebook\FacebookResponse->__construct(Object(Facebook\FacebookRequest), '{"error":{ "mess...
#4 path/includes/facebook/src/Facebook/Facebook.php(504): Fac in path/includes/facebook/src/Facebook/Exceptions/FacebookResponseException.php on line 100

Just in case, I will clarify that I gave the application all the rights that are possible.
Tell me, please, what is the problem.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question