Facebook PHP SDK を使用する小さな動的 Facebook タブがあります。これにはファンゲート機能があり、スクリプトはセッションを使用して getRequest を保存するため、ファンゲートはタブ内のサブページでも機能します。
うまくいきましたが、スクリプトを SSL を使用して他のホスティング サーバーに移動したところ、セッションが新しいサーバーに保存されなくなったようです。
どこに問題があるのか 誰にも分かりますか?
index.php スクリプトは次のとおりです。
<?php
session_start();
require 'src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => '419696674760950',
'secret' => 'THE SECRET',
));
$user = $facebook->getUser();
if ($user) {
try {
$likes = $facebook->api("/me/likes/145577828869070");
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();
$signedRequest = $facebook->getSignedRequest();
if(isset($signed_request)) $_SESSION['signedRequest'] = $signed_request;
else $signed_request = $_SESSION['signedRequest'];
$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":
$_SESSION['signedRequest'];
// If a fan is on your page
if ($like_status) {
include('leftside.html'); include('informace.html');
} else {
// If a non-fan is on your page
include ("nonfan2.html");}
break;
case "2": include('reference.html'); break;
case "3": include('clanky.html'); ;break;
case "4":
$_SESSION['signedRequest'];
// 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;
default:
$_SESSION['signedRequest'];
// If a fan is on your page
if ($like_status) {
include('leftside.html'); include('informace.html');
} else {
// If a non-fan is on your page
include ("nonfan2.html");}
}
include ("footer.html");
?>