PHP code example of compwright / x-hub-signature
1. Go to this page and download the library: Download compwright/x-hub-signature library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
compwright / x-hub-signature example snippets
use Compwright\XHubSignature;
use InvalidArgumentException;
$signer = new XHubSignature\Sha256();
// Generate the signature header for an outbound webhook, i.e.
//
// X-Hub-Signature-256: sha256=...
//
$headerName = $signer->getHeaderName();
$headerValue = $signer->sign($requestBody, $secret);
$signatureHeader = $headerName . ': ' . $headerValue;
// Verify an inbound webhook
$isValid = $signer->verify($signatureHeaderValue, $requestBody, $secret);
if ($isValid === false) {
throw new InvalidArgumentException('Bad Request');
}