stringfacebookaccess-tokeninvalidargumentexception

Facebook access token error when opening from link


He there,

I am working on a facebook app, which is working fine. I have one problem however; when I send somebody a link to visit the site and have them login, I receive an error message at my login callback page. This does not happen when the url is typed directly in the browser. Am I missing something here?

Error message:

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'The default access token must be of type "string" or Facebook\AccessToken' in /home/ckreeftmeijer/public_html/foundation/vendor/facebook/php-sdk-v4/src/Facebook/Facebook.php:298 Stack trace: #0 /home/ckreeftmeijer/public_html/foundation/login-callback.php(35): Facebook\Facebook->setDefaultAccessToken(NULL) #1 {main} thrown in /home/ckreeftmeijer/public_html/foundation/vendor/facebook/php-sdk-v4/src/Facebook/Facebook.php on line 298 

My acces token is string, as defined by

$_SESSION['facebook_access_token'] = (string) $accessToken; 

so I don't see why this is happening.

Thanks in advance


Solution

  • Found the answer.

    It was my $loginUrl. I forget to add www.

    Works fine now. Thank you for taking the time to respond