Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

facebook registration plugin


Guest

Recommended Posts

Posted

Hi

 

I am using a Facebook registration plugin and playing round with it so I can get my head round it on my own website and when I use it it says I have registered but it's not storing the data in the users table I created in the database

 

the code that inserts the data is below

 

$result = mysql_query("INSERT INTO users (name, email, password) VALUES ('$name', '$email', '$password')");

 

 

Am I doing it wrong somewhere, below is the coding that is supposed to save the data to the database table

 

<?php
require('includes/application_top.php');
require(DIR_WS_INCLUDES . 'template_top.php');
?>
<?php
include ("db.php");
define('FACEBOOK_APP_ID', 'facebook app id'); // Place your App Id here
define('FACEBOOK_SECRET', 'facebook secret id number'); // 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;
}

// 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"];
// Inserting into users table
$result = mysql_query("INSERT INTO users (name, email, password) VALUES ('$name', '$email', '$password')");

if($result){
echo "Successfully registered";
}
else
{
// Error in storing
}
}
else
{
//echo '$_REQUEST is empty';
}
?>
<div id="fbsuccess">
Thank you for registering on our website using your Facebook information
<br />
<a href="index.php">Home</a>
</div>
<?php
require(DIR_WS_INCLUDES . 'template_bottom.php');
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

 

This is the iframe facebook registration form plugin

 

<iframe src='http://www.facebook.com/plugins/registration.php?
				    client_id=app id number&
				    redirect_uri=url&
				    fields=[
				    {"name":"name"},
				    {"name":"email"},
				    {"name":"password"},
				    {"name":"captcha"},
				    ]'
				    scrolling="auto"
				    frameborder="no"
				    style="border:none"
				    allowTransparency="true"
				    width="450"
				    height="450">
		    </iframe>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...