Error in facebook library. "Malformed access token"

0

I'm trying to get the user's contact information from Facebook. For this I am using the Facebook PHP SDK.

I can generate the login url correctly. However, when I try to get the information I get the error "Malformed access token".

The code I'm currently trying is:

$code = Input::get('code'); // Código que vem na queryString

Session::put('facebook', Input::all());

$facebook = $this->facebook_api_instance();

// Aqui é onde eu passo o código OAuth2 e é gerado um erro
$request = $facebook->request('GET', '/me/friends', [], $code);

$response = $facebook->getClient()->sendRequest($request);
    
asked by anonymous 16.11.2015 / 17:40

1 answer

0

I discovered what it was.

Facebook uses the native PHP session internally to save two data from the url, which is state and code . But Laravel , which is the framework I use, does not use the native PHP session.

I declined to give a session_start just because of this library.

I created an adaptation for the library, to use the laravel session.

link

Now it's working, as expected!

Example:

$api_data = Config::get('facebook_api');

$facebook = new Facebook([
    'app_id'                  => $api_data['app_id'],
    'app_secret'              => $api_data['app_secret'],
    'persistent_data_handler' => new Laravel3SessionPersistentData,
]);
    
25.11.2015 / 12:28