如何检查通过facebook php sdk登录我网站的用户是否喜欢我的网页,以便向他展示一些秘密内容......
答案 0 :(得分:1)
如果您具有相应的权限,则可以访问用户的Likes属性:然后,您可以检查返回的列表以查看您的URL是否在列表中。你可以使用这样的东西:
$likes = Facebook::api('/me/likes','GET');
答案 1 :(得分:0)
以下是使用检查$signed_request->page->liked
:
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 "This content is for Fans only!";
} else {
echo "Please click on the Like button to view this tab!";
}
}