Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5844403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:17:14+00:00 2026-05-22T12:17:14+00:00

So I’m fairly new to Facebook dev and PHP dev so please bare with.

  • 0

So I’m fairly new to Facebook dev and PHP dev so please bare with.

I’ve created an iframe Facebook application. I have no trouble grabbing a signed request and using that information to do basic tasks on my page.

The real problem happens when I start navigating around my application within Facebook. I seem to lose my signed request information.

I have my PHP code included on every page and I still can’t retain my signed request or session…. whatever its called.

I’ve pasted my basic PHP code below.

<?php

include_once "../lib/facebook.php";

$facebook = new Facebook(array(
"appId"  => FACEBOOK_APP_ID,
"secret" => FACEBOOK_SECRET_KEY,
"cookie" => true,
"domain" => SERVER_DOMAIN
));

function parse_signed_request($signed_request, $secret) {
  list($encoded_sig, $payload) = explode(".", $signed_request, 2); 

  // decode the data
  $sig = base64_url_decode($encoded_sig);
  $data = json_decode(base64_url_decode($payload), true);

  if (strtoupper($data["algorithm"]) !== "HMAC-SHA256") {
    error_log("Unknown algorithm. Expected HMAC-SHA256");
    return null;
  }

  // check sig
  $expected_sig = hash_hmac("sha256", $payload, $secret, $raw = true);
  if ($sig !== $expected_sig) {
    error_log("Bad Signed JSON signature!");
    return null;
  }

  return $data;
}

function base64_url_decode($input) {
  return base64_decode(strtr($input, "-_", "+/"));
}


session_start();

if (isset($_SESSION['fb_data'])) {
    $data = $_SESSION['fb_data'];
} else {
    $data = parse_signed_request($_REQUEST["signed_request"], FACEBOOK_SECRET_KEY);
    $_SESSION['fb_data'] = $data;
}

session_write_close();

$page_id = $data["page"]["id"];
$like_status = $data["page"]["liked"];

?>
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:17:15+00:00Added an answer on May 22, 2026 at 12:17 pm

    The signed_request is only passed into your page when it is first loaded as a Facebook Canvas page. The signed_request is passed in as a POST variable. If you are navigating to different pages at the iframe level instead of the top level, you will lose that signed_request parameter.

    For example, when user loads this page:

    http://apps.facebook.com/test_app/ 
    

    Facebook will load this inside its IFrame:

    http://yourserver.com/test_app/
    
    • while passing in signed_request as a POST variable.

    If you then navigate to different pages using the following tag:

    <a href="http://yourserver.com/test_app/page2"> Page 2 </a>
    

    signed_request parameter will be lost.

    Instead, you can either pass through the signed_request parameter as a GET variable:

    <a href="http://yourserver.com/test_app/page2?signed_request=xxxxx"> Page 2 </a>
    

    Or reload the page at top level:

    <a target="_top" href="http://apps.facebook.com/test_app/page2"> Page 2 </a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.