FB CanvasLoginHelper object is missing information for some users causing a NULL session for those users.
Does anyone have any ideas on how to fix this? Any ideas why the $helper would fail for some users but work for others or why it would fail temporarily for some users?
Using PHP SDK 5.0.0
Code has been in use for about 2 years, running properly for all users without any significant changes over that period of time. It suddenly stopped working a few nights ago. Some users weren't affected at all, some were affected for a short time (about 16 hours) and others are still affected.
No errors are generated.
See code below.
It affects all browsers. Tried having the users use multiple bronwers, clearing all caches and doing a device restart. Nothing fixed the problem.
I did var_dumps of the objects and compared the results for users who are working vs those that are failing. Here are the differences in var_dump output.
$helper :
["rawSignedRequest"] is much shorter (188 characters vs 546)
no [expires] property
no [oauth] property
no [user_id] property
$signed_request :
["rawSignedRequest"] is shorter
no [oauth_token] property
no [user_id] property
$session :
returns NULL
I've searched for similar issues without any luck. Most identify a missing session_start() after the opening
<?php
session_start();
require('../Session/init.php');
require_once '../Facebook/autoload.php';
FacebookSession::setDefaultApplication( 'myAppId','mySecret' );
$helper = new FacebookCanvasLoginHelper();
var_dump($helper);
try {
$session = $helper->getSession();
$signedRequest = $helper->getSignedRequest();
var_dump($signedRequest);
} catch(FacebookRequestException $ex) {
logError('FBIndex - New Session', $ex->getCode(), $ex->getMessage());
echo "<div>Error connecting with FB. Please try again later.</div>";
exit();
} catch(\Exception $ex) {
logError('FBIndex - New Session', $ex->getCode(), $ex->getMessage());
echo "<div>Error connecting with FB. Please try again later.</div>";
exit();
}
var_dump($session);
if ($session) {
etc...