Skip to content

Instantly share code, notes, and snippets.

@lav45
Created March 31, 2017 23:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lav45/ee538cd33db1eb0c220572a8123ef870 to your computer and use it in GitHub Desktop.
Save lav45/ee538cd33db1eb0c220572a8123ef870 to your computer and use it in GitHub Desktop.
<?php
$secret = 'secret key';
list($hashAlgo, $signature) = explode('=', $_SERVER['HTTP_X_HUB_SIGNATURE']);
$payload = $HTTP_RAW_POST_DATA ?: file_get_contents('php://input');
$compute = hash_hmac($hashAlgo, $payload, $secret);
$valid = hash_equals($compute, $signature);
if ($valid === false) {
exit('Incorrect data');
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment