daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Aug 21st, 2018 56 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. Example code of FBML App that uses signed_request?
  2. function parse_signed_request($signed_request, $secret) {
  3.   list($encoded_sig, $payload) = explode('.', $signed_request, 2);
  4.  
  5.   // decode the data
  6.   $sig = base64_url_decode($encoded_sig);
  7.   $data = json_decode(base64_url_decode($payload), true);
  8.  
  9.   if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
  10.     error_log('Unknown algorithm. Expected HMAC-SHA256');
  11.     return null;
  12.   }
  13.  
  14.   // check sig
  15.   $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
  16.   if ($sig !== $expected_sig) {
  17.     error_log('Bad Signed JSON signature!');
  18.     return null;
  19.   }
  20.  
  21.   return $data;
  22. }
  23.  
  24. function base64_url_decode($input) {
  25.   return base64_decode(strtr($input, '-_', '+/'));
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top