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 6235607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:41:59+00:00 2026-05-24T10:41:59+00:00

I tried to get the user_id from the decoded data. As seen below, the

  • 0

I tried to get the user_id from the decoded data.
As seen below, the same thing is done with algorithm.
Problem is, when registering, the user_id field in the database is empty so it doesn’t really work.

What have I done wrong?
Facebook link: https://developers.facebook.com/docs/plugins/registration/
This is my process php.

<?php
define('FACEBOOK_APP_ID', ''); // Place your App Id here
define('FACEBOOK_SECRET', ''); // Place your App Secret Here

// No need to change the function body
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;
}
$user_fbid = $data['user_id'];

// 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, '-_', '+/'));
}
if ($_REQUEST) 
{
$response = parse_signed_request($_REQUEST['signed_request'],
FACEBOOK_SECRET);

$name = $response["registration"]["name"];
$email = $response["registration"]["email"];
$password = $response["registration"]["password"];
$gender = $response["registration"]["gender"];
$dob = $response["registration"]["birthday"];

// Connecting to database
mysql_connect("", "", "")or die("cannot connect");
mysql_select_db("")or die("cannot select DB");

// Inserting into users table
$result = mysql_query("INSERT INTO `users` (`fullname`, `email`, `password`, `gender`, `dob`, `user_id`) VALUES ('$name', '$email', '$password', '$gender', '$dob', '$user_fbid')");

if($result){
// User successfully stored
}
else
{
// Error in storing
}
}
else 
{
echo '$_REQUEST is empty';
}
?>
  • 1 1 Answer
  • 0 Views
  • 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-24T10:41:59+00:00Added an answer on May 24, 2026 at 10:41 am

    You define $user_fbid in the parse_signed_request()-function and then output it outside the function when it’s not in scope anymore 🙂

    But with $response = parse_signed_request($_REQUEST['signed_request'],
    FACEBOOK_SECRET);
    you return the $data-array, where the user_id is in, to $response and then you can access it from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

has anyone ever tried to get the list of all the movieclips (even the
I'm coding some c# against Active Directory and have tried endlessly to get this
I tried the following code to get an alert upon closing a browser window:
I tried running 'diff' against two source directories get a patch file with a
I get the following error when attempting to install RubyGems . I've tried Googling
I tried to install beautifulsoup. I get such an error: <-- snip --> raise
I just don't get it. Tried on VC++ 2008 and G++ 4.3.2 #include <map>
I tried using "cap rollback" but I get the following error: $ cap rollback
Have you managed to get Aptana Studio debugging to work? I tried following this,
To make this easier to understand, I will present the exact same problem as

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.