The JSON body contains some fields such as MessageId, Message, and Type, but other fields are missing.
The PHP SNS SDK requires all of these fields [1] and throws an exception if any are missing:
- Message
- MessageId
- Timestamp
- TopicArn
- Type
- Signature
- SigningCertURL or SigningCertUrl
- SignatureVersion
In my implementation I'm already skipping signing for non-production (my other sns testing tools don't sign the requests) but the fields would still need to exist for the Message object to be constructed, such as via Message::fromRawPostData method.
In my "manually trigger sns handler" testing code code, I'm using the following field values:
| Field |
Value |
| MessageId |
guid |
| Signature |
EXAMPLE |
| SignatureVersion |
1 |
| SigningCertURL |
http://example.com |
| Timestamp |
current unix time, i.e. php gmdate('c') |
| TopicArn |
arn:aws:sns:us-west-2:123456789012:MyTopic but the actual topic would be better |
| Type |
Notification |
I think I can see how to patch these other fields in, so I might have a go at it myself.
[1] https://github.com/aws/aws-php-sns-message-validator/blob/master/src/Message.php#L11
The JSON body contains some fields such as
MessageId,Message, andType, but other fields are missing.The PHP SNS SDK requires all of these fields [1] and throws an exception if any are missing:
In my implementation I'm already skipping signing for non-production (my other sns testing tools don't sign the requests) but the fields would still need to exist for the
Messageobject to be constructed, such as viaMessage::fromRawPostDatamethod.In my "manually trigger sns handler" testing code code, I'm using the following field values:
EXAMPLE1http://example.comgmdate('c')arn:aws:sns:us-west-2:123456789012:MyTopicbut the actual topic would be betterI think I can see how to patch these other fields in, so I might have a go at it myself.
[1] https://github.com/aws/aws-php-sns-message-validator/blob/master/src/Message.php#L11