I am trying to integrate facebook for my canvas app. When i run app from facebook with following code
// init app with app id (APPID) and secret (SECRET)
FacebookSession::setDefaultApplication('xx','xx');
$helper = new FacebookCanvasLoginHelper();
try {
$data = array('oauth_token' => 'token');
$data['algorithm'] = 'HMAC-SHA256';
$data['issued_at'] = time();
$base64data = base64_encode(json_encode($data));
$rawSig = hash_hmac('sha256', $base64data, 'app_Secret', true);
$sig = base64_encode($rawSig);
$signedRequest = $sig.'.'.$base64data;
$_GET['signed_request'] = $signedRequest;
$session = $helper->getSession();
} catch(FacebookRequestException $ex) {
echo $ex;
} catch(\Exception $ex) {
echo $ex;
}
The entire page just turns blank white because of $_GET['signed_request'] = $signedRequest;.
What should I do to get login. If i just do $session = $helper->getSession();
instead of Get i get invalid signed paramters oAuth data missing.
Thanks guys!
My approach:
And in your html put a javascript:
Your PHP should be:
And then somewhere in your HTML:
If you want to ask for extra permission, add the scope parameter in the URL like this:
That will redirect the page to the login page, and then come back to your canvas app with the proper permission.
This shouldn't work like this as it's using Javascript with the PHP SDK. It's a bug that is being addressed by Facebook which you can follow here:
https://developers.facebook.com/bugs/722275367815777
I'll edit the answer if that bug ever gets resolved.