Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
There are no tools. Only your knowledge of web technologies and server languages.
The only thing facebook will give you is information about the current user. You can see her.
function parse_signed_request($signed_request = false, $secret) {
if( $signed_request === false )
$signed_request = $_REQUEST['signed_request'];
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, '-_', '+/'));
}
$page = parse_signed_request(false , 'bd84f7d726a40620df9781d72ca67994' );
Пример на PHP
<source lang="php">
function parse_signed_request($signed_request = false, $secret) {
if( $signed_request === false )
$signed_request = $_REQUEST['signed_request'];
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, '-_', '+/'));
}
$page = parse_signed_request(false , 'Your_secret_code_application' );
var_dump($page);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question