Created
November 12, 2014 08:30
-
-
Save mindplay-dk/9943989b66ad1ce70cd8 to your computer and use it in GitHub Desktop.
GitHub service hook example in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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