脸书应用程序粉丝门显示非粉丝


Facebook app fan gate showing non fan

我已经执行了以下操作,但即使作为一名粉丝,它也只是在说"NON-fan"
我已经上传了facebook.php文件,并添加了我认为正确的应用程序设置。我做错了什么?

我的应用程序设置如下:

Canvas URL: http://www.mysite.com/myapp/  
Secure Canvas URL: https://www.mysite.com/myapp/  
Page Tab URL: http://www.mysite.com/myapp/index.php  
Secure Page Tab URL: https://www.mysite.com/myapp/index.php

我在服务器上对我的index.php文件进行了如下编码:

<?php
require 'facebook.php';
//uploaded into same directory as index.php
$app_id = "myappid";
$app_secret = "myappsecret";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
$like_status = $signed_request["page"]["liked"];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>my app</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.Canvas.setSize();
}
// Do things that will sometimes call sizeChangeCallback()
function sizeChangeCallback() {
FB.Canvas.setSize();
}
</script>
<base target='_blank' />
</head>
<body>
<div id="container">
<?php if ($like_status) { ?>
FAN
<?php } else { ?>
NON-FAN
<?php } ?>
</div>
<div id="fb-root"></div>
<script src="https://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'myappid',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
window.fbAsyncInit = function() {
FB.Canvas.setAutoResize();
}
</script>
<script>
FB.Event.subscribe('edge.create',
function(response){
top.location.href = 'myappurl';
});
</script>
</body>
</html>

这里描述的方法,通常会完成查找的技巧,无论用户是否是页面的粉丝。

如果你想按照自己的方式来做,你能在分配了一些值后提供var_dump($like_status)吗?

请记住,signed_request参数仅在第一页加载到iframe时可用——一旦您开始在应用程序中导航,就不会再有signed_rerequest了。(因此,一旦获得签名请求或类似状态,就必须将其保存到会话中。)

如果即使在第一次加载时也没有得到任何数据,则var_dump变量$_REQUEST的内容,以查看该值是否存在。如果是,那么你的应用程序机密很可能是错误的——因为如果Facebook::getSignedRequest无法通过使用应用程序机密计算正确的哈希来验证签名的请求,它将返回null。请仔细检查您的应用程序秘密是否真的正确。