PHPackages                             aws/aws-php-sns-message-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. aws/aws-php-sns-message-validator

ActiveLibrary[Queues &amp; Workers](/categories/queues)

aws/aws-php-sns-message-validator
=================================

Amazon SNS message validation for PHP

1.10.0(1y ago)21421.5M—0.6%58[3 issues](https://github.com/aws/aws-php-sns-message-validator/issues)[1 PRs](https://github.com/aws/aws-php-sns-message-validator/pulls)20Apache-2.0PHPPHP &gt;=8.1CI passing

Since Jul 1Pushed 6mo ago19 watchersCompare

[ Source](https://github.com/aws/aws-php-sns-message-validator)[ Packagist](https://packagist.org/packages/aws/aws-php-sns-message-validator)[ Docs](http://aws.amazon.com/sdkforphp)[ RSS](/packages/aws-aws-php-sns-message-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (14)Used By (20)

Amazon SNS Message Validator for PHP
====================================

[](#amazon-sns-message-validator-for-php)

[![@awsforphp on Twitter](https://camo.githubusercontent.com/c17b2c5b53b824f61a1500d2c0f70eb94ad3d85ab13798c417e499e700878b93/687474703a2f2f696d672e736869656c64732e696f2f62616467652f747769747465722d253430617773666f727068702d626c75652e7376673f7374796c653d666c6174)](https://twitter.com/awsforphp)[![Total Downloads](https://camo.githubusercontent.com/dfabbcdf1fb67466d88cce0e984522f1070f80ff9c9a97ad240c0938e28d99c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6177732f6177732d7068702d736e732d6d6573736167652d76616c696461746f722e7376673f7374796c653d666c6174)](https://packagist.org/packages/aws/aws-php-sns-message-validator)[![Build Status](https://camo.githubusercontent.com/76871fb38022ab1d09fddafa8a35a89ab72e6add4345e7dfa2469c620664a09d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6177732f6177732d7068702d736e732d6d6573736167652d76616c696461746f722e7376673f7374796c653d666c6174)](https://travis-ci.org/aws/aws-php-sns-message-validator)[![Apache 2 License](https://camo.githubusercontent.com/41ef4d0b60e3171f9a999660fd85bd89e991e88079933e81df74414f1cf7282b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6177732f6177732d7068702d736e732d6d6573736167652d76616c696461746f722e7376673f7374796c653d666c6174)](http://aws.amazon.com/apache-2-0/)

The **Amazon SNS Message Validator for PHP** library allows you to validate that incoming HTTP(S) POST messages are valid Amazon SNS notifications. This library is standalone and does not depend on the AWS SDK for PHP or Guzzle; however, it does require PHP 8.1+ and that the OpenSSL PHP extension is installed.

Jump To:

- [Basic Usage](_#Basic-Usage_)
- [Installation](_#Installation_)
- [About Amazon SNS](_#About-Amazon-SNS_)
- [Handling Messages](_#Handling-Messages_)
- [Testing Locally](_#Testing-Locally_)
- [Contributing](_#Contributing_)

Basic Usage
-----------

[](#basic-usage)

To validate a message, you can instantiate a `Message` object from the POST data using the `Message::fromRawPostData`. This reads the raw POST data from the [`php://input` stream](http://php.net/manual/en/wrappers.php.php#wrappers.php.input), decodes the JSON data, and validates the message's type and structure.

Next, you must create an instance of `MessageValidator`, and then use either the `isValid()` or `validate()`, methods to validate the message. The message validator checks the `SigningCertURL`, `SignatureVersion`, and `Signature` to make sure they are valid and consistent with the message data.

```
