Created
September 11, 2018 03:21
-
-
Save faneder/2b640066e1dbac374205b53ce16f9b3e to your computer and use it in GitHub Desktop.
handle notification from AWS SNS
This file contains hidden or 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
<?php | |
use Notification; | |
use Aws\Sns\Message; | |
use Aws\Sns\MessageValidator; | |
use Aws\Sns\Exception\InvalidSnsMessageException; | |
class SNSController extends Controller | |
{ | |
public function handleNotification() | |
{ | |
$message = Message::fromRawPostData(); | |
$validator = new MessageValidator(); | |
// Validate the message | |
try { | |
$validator->validate($message); | |
} catch (InvalidSnsMessageException $e) { | |
Log::error('SNS Message Validation Error: ' . $e->getMessage()); | |
} | |
// find which notification is failing, you can notify the sender to change the correct email address | |
$notification = Notification::where('ses_message_id', $message['Message']['mail']['messageId'])->first(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment