我想我快要疯了。我不能让它工作。
我只是想检查一下用户是否喜欢我在iFrame应用程序中使用javascript的页面。
FB.api({
method: "pages.isFan",
page_id: my_page_id,
}, function(response) {
console.log(response);
if(response){
alert('You Likey');
} else {
alert('You not Likey :(');
}
}
);这将返回: False
但我是我的页面的粉丝,所以它不应该返回true吗?!
发布于 2011-02-24 12:16:39
我也为这件事绞尽脑汁。只有当用户为不理想的内容授予扩展权限时,您的代码才会起作用。
Here's another approach.
简而言之,如果你打开了画布的OAuth 2.0高级选项,Facebook将会在你的标签应用程序中请求的每个页面上发送一个$_REQUEST['signed_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 "This content is for Fans only!";
} else {
echo "Please click on the Like button to view this tab!";
}
}https://stackoverflow.com/questions/5093398
复制相似问题