Skip to content

Instantly share code, notes, and snippets.

@mindplay-dk
Created November 12, 2014 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindplay-dk/9943989b66ad1ce70cd8 to your computer and use it in GitHub Desktop.
Save mindplay-dk/9943989b66ad1ce70cd8 to your computer and use it in GitHub Desktop.
GitHub service hook example in PHP
<?php
// basic GitHub service hook example
$payload = file_get_contents("php://input");
$secret_key = 'secret';
$computed_signature = 'sha1=' . hash_hmac('sha1', $payload, $secret_key, false);
$posted_signature = $_SERVER['HTTP_X_HUB_SIGNATURE'];
if ($computed_signature !== $posted_signature) {
file_put_contents(__DIR__ . '/test.txt', 'INVALID');
throw new RuntimeException("invalid payload signature");
}
file_put_contents(__DIR__ . '/test.txt', $payload);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment