Originariamente inviato da vnt54
Quale codice?
ops questo... a grandi linee è quello predefinito che si trova nel facebook app,
codice:
<?php
define('FACEBOOK_APP_ID', '564646346363535');
define('FACEBOOK_SECRET', '2555554e352c88225555550a');
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);
echo '<pre> Benvenuto '; print_r ($response["registration"]["name"]); echo '</pre>
';
} else {?>
<iframe src="https://www.facebook.com/plugins/registration?
client_id=132025016958704&
redirect_uri=http%3A%2F%2Fspazifluidi.altervista.org%2Fblog%2Fblog%2F&
fields=name,email"
scrolling="auto"
frameborder="yes"
style="border:none"
allowTransparency="true"
width="90%"
height="330">
</iframe><?
}
?>