Created
February 28, 2013 01:01
-
-
Save poisa/5053319 to your computer and use it in GitHub Desktop.
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
require 'vendor/autoload.php'; | |
use Aws\Sns\Validator\SnsValidator; | |
$incomingMessage = json_decode($HTTP_RAW_POST_DATA); | |
try { | |
// Case 1: | |
// Full auto pilot mode (this detects the strategy based on the 'Type' property of the incoming message | |
$validator = new SnsValidator($incomingMessage); | |
// Case 2: | |
// Injecting the strategy by hand | |
$strategy = new Validator\Strategy\NotificationStrategy(); | |
$validator = new SnsValidator($incomingMessage, $strategy); | |
// Case 3a: | |
// Specifying the strategy via a constructor string | |
$validator = new SnsValidator($incomingMessage, 'Notification'); | |
// Case 3b: | |
// Specifying the strategy via a constructor string straight from the incoming data | |
$validator = new SnsValidator($incomingMessage, $incomingMessage->Type); | |
if ($validator->validate()) { | |
echo "Signature is valid\n"; | |
} else { | |
echo "Signature is invalid"; | |
} | |
} catch (Exception $e) { | |
echo $e->getMessage(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment