Пример Php:
<?php
$signedRequestObject = parse_signed_request( $_POST["signed_request"],YOUR_APPLICATION_SECRET );
if ($signedRequestObject["page"]){
// this means this signed_request was generated on a page
if ($signedRequestObject["page"]["liked"]){
// the page was liked
}
}
//used functions
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$sig = $this->base64_url_decode($encoded_sig);
$data = json_decode($this->base64_url_decode($payload), true);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
echo 'Unknown algorithm. Expected HMAC-SHA256 : ';
return false;
}
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
echo = 'Bad Signed JSON signature!';
return false;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
?>