<?php

require_once(__DIR__.'/../autoload.php');

// Create the validator for incoming requests.
$requestValidator = new \MessageBird\RequestValidator('YOUR_SIGNING_KEY');

// Set up the signed request from the PHP global variables.
$request = \MessageBird\Objects\SignedRequest::createFromGlobals();

if (!$requestValidator->verify($request)) {
    // The request was invalid, so respond accordingly.
    http_response_code(412);
}

<?php

require_once(__DIR__.'/../autoload.php');

// Create the validator for incoming requests.
$requestValidator = new \MessageBird\RequestValidator('YOUR_SIGNING_KEY');

// Set up the signed request from the PHP global variables.
try {
    $request = \MessageBird\Objects\SignedRequest::createFromGlobals();
} catch (\MessageBird\Exceptions\ValidationException $e) {
    // The request was missing expected values, so respond accordingly.
    http_response_code(412);
}

if (!$requestValidator->verify($request)) {
    // The request was invalid, so respond accordingly.
    http_response_code(412);
}

Update SignedRequest example to handle ValidationExceptions
Update SignedRequest example to handle ValidationExceptions

If expected values are missing or invalid when calling createFromGlobals() an exception is thrown.
The example now demonstrates how an implementation can handle this and respond cleanly.
