PHP code example of adgators / screenseed-webhook

1. Go to this page and download the library: Download adgators/screenseed-webhook 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/ */

    

adgators / screenseed-webhook example snippets


use AdGators\ScreenSeed\Webhook\Signature;
use AdGators\ScreenSeed\Webhook\Exceptions\InvalidSignatureFormatException;

$payload = file_get_contents('php://input');
$signatureHeader = $_SERVER['HTTP_SCREENSEED_SIGNATURE'];
$secret = $_ENV['SCREENSEED_WEBHOOK_SECRET'];

try {
    $signature = new Signature($signatureHeader);

    // verify the signature matches and is less than 30 seconds old
    if (! $signature->verify($payload, $secret, 30)) {
        http_response_code(401);
        exit('Invalid webhook signature');
    }
}
catch(InvalidSignatureFormatException $e) {
    exit($e->getMessage());
}