0
votes

I wanted to know , will this tag of Static FBML would work in IFrame anyway :-

fb : userlink uid="loggedinuser"

And my Second question is , Can We get User ID Through Cokkies stored rather using FBML as on iframe facebook wont allow us to access Users DATA. So Using Firebug I found we Get the Users Id. and is stored in cookie. I want the user to be Restricted for More than one time Access to my Iframe . So by getting The User ID I would like to check , whether the user had registered or not. and if he had Registered. He cant Register Twice .

I am trying it by Using Cokkies , But due to Lack of knowledge about JAVASCRIPT , I am not getting How to execute it.

1

1 Answers

0
votes

Put the following code in your iframe and you will get the logged in user id then check constraint on it .

<?php   

   function parse_signed_request($signed_request , $secret ) {
$signed_request = $signed_request ? $signed_request : $_REQUEST['signed_request'];
$secret = $secret ? $secret : your_app_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, '-_', '+/'));
}
  $request=$_REQUEST['signed_request']; 
  $appsecret = 'your_app_secret_key';
$new = parse_signed_request($request , $appsecret );
echo $new['user_id'];