Guest User

Untitled

a guest
May 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. <?php
  2. define('CLIENT_SECRET', 'my_shared_secret');
  3. function verify_webhook($data, $hmac_header){
  4. $calculated_hmac = base64_encode(hash_hmac('sha256', $data, CLIENT_SECRET, true));
  5. return ($hmac_header == $calculated_hmac);
  6. }
  7. $hmac_header = $_SERVER['X-NINJAVAN-HMAC-SHA256'];
  8. $data = file_get_contents('php://input');
  9. $verified = verify_webhook($data, $hmac_header);
  10. error_log('Webhook verified: '.var_export($verified, true)); //check error.log to see result
Add Comment
Please, Sign In to add comment