I am implementing the edit url FB Page Tab App. But it needs the initialization which should happen when the app is added to a fanpage by the admin.
I am looking for the initial callback/notification to my app-url when the app is loaded on the fanpage. (I have looked at this already - http://developers.facebook.com/docs/authentication/signed_request/).
I am looking for a sample that shows the handling of the signed_request in this case, from the fan-page-load and what details are available/etc..
Thanks !
Here's a sample of handling the signed request:
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
// decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}
// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
in $data there will be a "page" object that has a "admin" boolean. This will tell you if the current user of the page tab application is an admin of the page that the app is a tab of.