我正在创建一个 facebook 标签页,我想使用扇形门控。
我以前使用过扇形门控并且没有任何问题,但这就像 4 个月前一样。而且我使用的是相同的 PHP,但这次我遇到了问题。
请参阅下面我的应用程序的基本代码和扇形门条件语句......
但由于某种原因,我得到了这个错误......
注意:未定义的索引:第 126 行 /home/sites/example.co.uk/www/competition/index.php 中的 signed_request 注意:未定义的偏移量:/home/sites/example.co.uk/www/competition/ 中的 1第 128 行的 index.php 喜欢
诡异的..
我以前从来没有使用过这个问题,facebook改变了它的工作方式吗?
任何帮助将不胜感激。
<?php
$fb_app_id = '000000000000000';
$fb_secret = '00000000000000000000000000000000';
$fb_app_url = 'http://example.co.uk/competition';
$fb_tab_url = 'http://www.facebook.com/example/app_000000000000000';
$fb_channel = '//example.co.uk'
require 'src/facebook.php';
//Create facebook application instance.
$facebook = new Facebook(array(
'appId' => $fb_app_id,
'secret' => $fb_secret,
'cookie' => true,
));
?>
<!DOCTYPE html>
<html>
<head>
<meta property="fb:app_id" content="<?php echo $fb_app_id ?>" />
</head>
<body>
<div id="fan-gate">
<?php
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
if (empty($data["page"]["liked"])) {
?>
LIKE US...
<?php } else { ?>
<strong>YOU'VE LIKED OUR PAGE, THANKS!!!</strong>
<?php } ?>
</div>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '<?php echo $fb_app_id ?>',
channelUrl : '<?php echo $fb_channel ?>/channel.html', // Channel File
cookie: true,
xfbml: true,
oauth: true,
status: true
});
FB.Canvas.setAutoGrow(true);
};
</script>
</body>
</html>
也试过这个,但它总是说第二个条件,即使我不喜欢这个页面。
<?php
$fb_app_id = '000000000000000';
$fb_secret = '00000000000000000000000000000000';
$fb_app_url = 'http://example.co.uk/competition';
$fb_tab_url = 'http://www.facebook.com/example/app_000000000000000';
$fb_channel = '//example.co.uk'
require 'src/facebook.php';
//Create facebook application instance.
$facebook = new Facebook(array(
'appId' => $fb_app_id,
'secret' => $fb_secret,
'cookie' => true,
));
?>
<!DOCTYPE html>
<html>
<head>
<meta property="fb:app_id" content="<?php echo $fb_app_id ?>" />
</head>
<body>
<div id="fan-gate">
<?php
$signed_request = $facebook->getSignedRequest();
$like_status = $signed_request["page"]["liked"];
if($like_status){
echo 'LIKE US...';
} else {
echo '<strong>YOU'VE LIKED OUR PAGE, THANKS!!!</strong>';
}
?>
</div>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '<?php echo $fb_app_id ?>',
channelUrl : '<?php echo $fb_channel ?>/channel.html', // Channel File
cookie: true,
xfbml: true,
oauth: true,
status: true
});
FB.Canvas.setAutoGrow(true);
};
</script>
</body>
</html>