Jake
Jake

Reputation: 171

Facebook app with multiple PHP pages

I'm building an iframe application with PHP and the Facebook SDK. On the first page there's an "download" button which links to the second page. On the second page I use the following code:

 $signed_request = $facebook->getSignedRequest();
$page_id = $signed_request["page"]["id"];
$page_admin = $signed_request["page"]["admin"];
$like_status = $signed_request["page"]["liked"];
if ($like_status) {
include('download.php');

}
else {
include('non-fan.php');
}

I want to provide the download ONLY for people who liked our Facebook page. For some reason the $signed_request variables are empty. How can I solve this?

Upvotes: 1

Views: 774

Answers (1)

marramgrass
marramgrass

Reputation: 1411

In the iframe, Facebook only posts the signed request on the initial load of the whole page. Subsequent pageloads within the iframe won't receive the post.

You can serialize the signed request variable and stash it in your session, then on each pageload check if you've got a fresh one, and if you haven't then grab it from your session.

Upvotes: 5

Related Questions