我已经表演了以下,但即使作为粉丝,它也只是说“非粉丝”。
我已经上传了 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>