I am using the FB facebook-php-sdk-v4-5.0-dev.zip API files.
I'm attempting to make the Facebook javascript and php SDKs work together. I have FB.login working find, I can make Graph requests, etc. Now I want to pass off the access token to my PHP code, and continue from there. I am initializing FB in javascript:
window.fbAsyncInit = function() {
FB.init({
appId : appId, //my appId
cookie : true, // enable cookies for session access
xfbml : true, // parse social plugins on this page
version : 'v2.2' // use version 2.2
});
And now that FB in initialized, I do some other work using the API, after which I push out to my php code with:
window.location.replace(<my url>.php);
Inside my PHP application, I have the following:
$fb = new Facebook\Facebook([ 'app_id' => <my app_id>,
'app_secret' => <my app_secret>
'default_graph_version' => 'v2.2',
]);
$jsHelper = $fb->getJavaScriptHelper();
try
{
$accessToken = $jsHelper->getAccessToken();
}
catch(Facebook\Exceptions\FacebookResponseException $e)
{
// When Graph returns an error
print('Graph returned an error: ' . $e->getMessage() );
exit;
}
catch(Facebook\Exceptions\FacebookSDKException $e)
{
// When validation fails or other local issues
print( 'Facebook SDK returned an error: ' . $e->getMessage() );
exit;
}
if (isset($accessToken))
{
print("Logged in already");
}
else
{
print("Not logged in");
}
What I see is "Not logged in". From what I can tell, no cookie is generated (I dumped out $_COOKIE at the top of my PHP file). I have also monitored the network calls, and can see no cookie coming down from Facebook on my oauth requests... which is where I would assume that such a cookie would come from.
Thanks, Andy