如何在不请求任何其他权限的情况下测试用户是否是我的Facebook页面的粉丝,就像您在[无关的Facebook垃圾邮件应用程序的链接已删除]中看到的那样。
答案 0 :(得分:0)
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, '-_', '+/'));
}
?>