I have been having some trouble with the facebook SDK, specifically retrieving an access token. The App is set up on Facebook correctly and has been given permission. As far as I can tell, the code is correct and I am not sure what is going wrong with getAccessToken().
$facebook->getAccessToken(); is returning "12345678|abcdefghijklmnop", basically some kind of variable which is made up of the App ID and Secret ID separated by a |
$facebook->getUser(); is returning '0'
<?php
require_once("facebook.php"); //Up-to-date SDK files from Git
$app_id = "12345678"; //replaced with fake
$app_secret = "abcdefghijklmnop"; //replaced with fake
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true; //I have tried 'false' here as well
));
$token = $facebook->getAccessToken();
?>
Thank you in advance!
$facebook->getAccessToken();
is returning"12345678|abcdefghijklmnop"
, basically some kind of variable which is made up of the App ID and Secret ID separated by a |From Facebook SDK:
Your access token will be
APP ID|APP SECRET
which is the application token, orA RANDOM TOKEN HERE
, which is the user access token, when you have a user signed:When
getUser()
return0
(which is same asfalse
, and user not signed) you need to request a login, and authorization (if have not authorized yet) for your application:see available permissions types here: https://developers.facebook.com/docs/authentication/permissions/