We developed a facebook application as tab application using FBML. Now Facebook had deprecated the fbml and we are converting our application to iframe. For this the user can create a FB page and add the application to their facebook page. We are taking the user’s facebook page id and check in the DB with this page id and showing the data for that particular user. In the FBML tab application we are getting the facebook page id as a request($REQUEST[‘page_id’]). This seems to no longer work.
-
When we convert the application to IFRAME tab application, FB is not providing the page id. We are not using GRAPH API and there is any authentication before viewing the application. I had read from a forum that facebook signed request, we will get the page id and used the following code and not getting any data.
$sgrequest = $_REQUEST['signed_request']; $requestVal = parse_signed_request($sgrequest,$secret); print_r($requestVal); $_REQUEST['signed_request']['app_data'] 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('vctly987', $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, ‘-_’, ‘+/’));
} -
Is there any other way to get the page id of the fan page through javascript or any other method?
have you tried printing out $requestVal[page][id] after parsing the signed request?
according to the documentation, the signed request contains an array called ‘page’ that contains the key ‘id’. This stores the value of the page’s id number.