I am developing a Facebook app using Symfony2. In my index route (indexAction), I ask the user to login and then, I set the access token in this way in order to retrieve some info:
$helper = $fb->getCanvasHelper();
$accessToken = $helper->getAccessToken();
$fb->setDefaultAccessToken($accessToken);
Until here, everything works fine. The problem comes when I do a redirect in this way to other page of my app from my indexAction:
return $this->redirect($route, 301);
In the new page, if I try to execute the previous code to get the access token again, I get this message:
The default access token must be of type \"string\" or Facebook\\AccessToken at /home/promocionescentros/www/vendor/facebook/php-sdk-v4/src/Facebook/Facebook.php:298)"} []
Why is happening this? Can I only get the access token one time?
Thanks
Just replace:
$accessToken = $helper->getAccessToken();
with:
$accessToken = (string)$helper->getAccessToken();