Facebook how to keep facebook session
I hope that someone can help me. I am developing a Iframe application. I am using a mixture of PHP and Javascipt.
Everything works perfectly if you click on the facebook tab created in the facebook profile. However I have a second page which edit the some functionality in my page, If I navigate to this page, it seems to loose it's authentication, or login session.
The like button, goes to not-liked - (so it seems to me the session breaks).
How can I keep the facebook session, to the next page?
I have included the complete page of my nav.php (This is the page that facebook first access)
<?php require 'facebook.php';
$app_id = "MY-APP-ID";
$app_secret = "MY-APP-SECRET";
$apiKey = "1573bcaff76885d24c5ca93d93266a9e";
$app_url = "http://domain.com";
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
if ($_SERVER['HTTP_REFERER'] != 'http://domain.com/facebook/edit_page.php');
{
$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"];
if ($page_admin == 1) {
$oauth_token = $signed_request["oauth_token"];
}
}
if ($like_status) {
// If you like 开发者_JS百科the page this will show - START
}
else {}
if ($page_id == '12345') {
echo "content for 12344";
}
elseif ($page_id == '56789') {
echo "content for 56789";
} ?>
In this page I can see who is the owner of the page, and the LIKE button shows liked! how do I pass the authentication to a next page? so that the Like button stay Liked?
Any help would be appreciated!
Thanks
I have figured out the problem - In my case I needed to pass the getSignedRequest(); to all pages, for the session to stay in place.
精彩评论