0
我有这个index.php告诉什么包括。 我想在选项卡中带有粉丝选通选项的其中一个子页面。 有人可以帮我,告诉我我的代码有什么问题吗?我不是很喜欢php。Facebook选项卡 - 粉丝选通 - 不喜欢显示内容
<?php
require 'src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '262995697152250',
'secret' => '7ad8d22dc1b0224b4bb226d0085b4063',
));
$user = $facebook->getUser();
if ($user) {
try {
$likes = $facebook->api("/me/likes/286599224689000");
if(!empty($likes['data']))
echo "I like!";
else
echo "not a fan!";
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl(array(
'scope' => 'user_likes'
));
}
$signed_request = $facebook->getSignedRequest();
$page_id = $signed_request["page"]["id"];
$page_admin = $signed_request["page"]["admin"];
$like_status = $signed_request["page"]["liked"];
$country = $signed_request["user"]["country"];
$locale = $signed_request["user"]["locale"];
include ("header.php");
if(!isset($_GET['page'])) $_GET['page']="";
switch($_GET['page']) {
case "1": include('leftside.html'); include('informace.html'); break;
case "2": include('reference.html'); break;
case "3": include('clanky.html'); ;break;
case "4":
// If a fan is on your page
if ($like_status) {
include ("formular.html");
} else {
// If a non-fan is on your page
include ("nonfan.html");}
;break;
case "5": include('clanok1.html'); break;
case "6": include('clanok2.html'); break;
case "7": include('clanok3.html'); break;
case "8": include('clanok4.html'); break;
case "9": include('leftside.html'); include('vyhody.html'); break;
default: include('leftside.html'); include('informace.html');
}
include ("footer.html");
?>
说明问题更好 –
如果有人谁是安装此选项卡中的FB的风扇打开indexphp页= 4 - 即“4” _比则代替formular.html的_switch情况包含nonfan.html。看起来条件不在那里工作。 –
'signed_request'参数只会在初始加载到iframe时传递给您的应用程序;在随后的请求中,当用户浏览你的应用程序时,不会有更多的'signed_request' - 因此也没有更多信息,用户喜欢该页面。如果你的error_reporting设置为一个合理的值(也是display_errors),PHP会告诉你自己(请这么做)。将您从signed_request获得的数据保存到会话中,以便您可以在后续请求中访问它。 – CBroe