Facebook documentation is soo bad :(
After a while searching I found this:
You must have turned on all items in migration in app settings ! (sep. 2010)
public function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
// decode the data
$sig = $this->base64_url_decode($encoded_sig);
$data = json_decode($this->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;
}
public function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
$aData = parse_signed_request($_REQUEST['signed_request'],APP_SECRET);
$iUserId = $aData['user_id'];
Some stuff about php, java, js, ajax, android, linux, samsung smart tv, iphone ...
streda 29. septembra 2010
utorok 28. septembra 2010
Java - how to compare dates
One of ways.. easy :)
try {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date dateOne= df.parse("2010-09-12");
Date dateTwo= df.parse("2010-08-30");
if (d1.equals(dateTwo))
{
//TODO: do something
}else if (dateOne.before(dateTwo))
{
//TODO: do something
}else
{
//TODO: do something
}catch (ParseException e)
{
//TODO: show error
}
try {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date dateOne= df.parse("2010-09-12");
Date dateTwo= df.parse("2010-08-30");
if (d1.equals(dateTwo))
{
//TODO: do something
}else if (dateOne.before(dateTwo))
{
//TODO: do something
}else
{
//TODO: do something
}catch (ParseException e)
{
//TODO: show error
}
Prihlásiť na odber:
Príspevky (Atom)