许多Facebook应用程序在使用它之前会要求您“喜欢”它。怎么实现呢?它有特殊的API吗?
答案 0 :(得分:5)
FBML页面已被弃用,您现在只能创建iframe粉丝页面。当用户导航到您的页面时,Facebook会发送您需要解码的signed_request参数。 This article对如何操作进行了演练。
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!";
}
}
答案 1 :(得分:1)
如果您的应用是在页面标签页中加载的iframe,则可以使用signed_request。 http://developers.facebook.com/docs/authentication/signed_request/