当我检查使用是否喜欢我的页面时。我的应用程序正在获取用户的权限并将他带到我的域页面,并带有空白页。
当我删除我用来检查的代码时,它是否正常工作。
这是代码,我用来检查是否
$signed_request = $facebook->getSignedRequest();
$liked = $signed_request['page']['liked'];
if ( $liked ) :
else :
endif;
这段代码是否正确?
答案 0 :(得分:2)
我这样做:
$signed_request = $_REQUEST['signed_request'];
function parsePageSignedRequest() {
if (isset($_REQUEST['signed_request'])) {
$encoded_sig = null;
$payload = null;
list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2);
$sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
$data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true));
return $data;
}
return false;
}
if($signed_request = parsePageSignedRequest()) {
if($signed_request->page->liked) {
echo "FAN";
} else {
echo "NO FAN";
}
}