Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Gonzalo Ayuso:
Handling Amazon SNS messages with PHP, Lumen and CloudWatch
Jan 22, 2018 @ 16:46:51

Gonzalo Ayuso has posted a tutorial to his site showing how to handle incoming Amazon SNS messages with a combination of Lumen, CloudWatch and some plain PHP.

This days I’m involve with Amazon’s AWS and since I am migrating my backends to Lumen I’m going to play a little bit with AWS and Lumen. Today I want to create a simple Lumen server to handle SNS notifications. One end-point to listen to SNS and another one to emit notifications. I also want to register logs within CloudWatch.

He starts with the Lumen backend, creating a simple applications that hooks in the AWS and Logging service providers and defines the two routes ("push" and "read"). The post also includes the code for both the AWS and logging service providers and the SnsController. The end result (available on GitHub) then sends a basic SNS message and the response is captured and sent to CloudWatch.

tagged: amazon sns lumen cloudwatch tutorial application

Link: https://gonzalo123.com/2018/01/22/handling-amazon-sns-messages-with-php-lumen-and-cloudwatch/

AWS PHP Development:
Testing Webhooks Locally for Amazon SNS
Apr 08, 2014 @ 16:33:07

In a previous post the AWS for PHP blog showed how to set up webhooks for handling the callbacks from their SNS messaging service. In this next part of the series they continue the process, showing how you can test these hooks locally without needing to actually send the messages. This eliminates the need to deploy to a public-facing server just to test the hooks every time you need an update.

In a recent post, I talked about Receiving Amazon SNS Messages in PHP. I showed you how to use the SNS Message and MessageValidator classes in the AWS SDK for PHP to handle incoming SNS messages. The PHP code for the webhook is easy to write, but can be difficult to test properly, since it must be deployed to a server in order to be accessible to Amazon SNS. I'll show you how you can actually test your code locally with the help of a few simple tools.

Using PHP's own built-in webserver and a tool called ngrok to tunnel from the public internet to a local server. He includes the commands to set up the PHP script directory, the code to intercept the POSTed data from the request, validate it and send the subscription confirmation request. He helps you create an SNS "topic" through the management console and walks you through a sample test request while tailing the logs.

tagged: aws amazon sns webhook testing local server ngrok tutorial

Link: http://blogs.aws.amazon.com/php/post/Tx2CO24DVG9CAK0/Testing-Webhooks-Locally-for-Amazon-SNS

AWS PHP Development:
Receiving Amazon SNS Messages in PHP
Apr 01, 2014 @ 15:53:14

The Amazon Web Services PHP Development blog has a new post from Jeremy Lindblom showing you how you can receive inbound SNS messages via a webhook on your application.

Amazon Simple Notification Service (Amazon SNS) is a fast, fully-managed, push messaging service. Amazon SNS can deliver messages to email, mobile devices, Amazon SQS queues, and HTTP/HTTPS endpoints. [...] Though you can certainly subscribe your email address to receive SNS messages from service events like these, your inbox would fill up rather quickly. There is great power, however, in being able to subscribe an HTTP/HTTPS endpoint to receive the messages. This allows you to program webhooks for your applications to easily respond to various events.

Using the AWS SDK for PHP you can set up a listening script that can receive the message and handle subscription confirmations, message signature validation and handling the notifications.

tagged: amazon aws sns message receive webhook sdk

Link: http://blogs.aws.amazon.com/php/post/Tx2G9D94IE6KPAY/Receiving-Amazon-SNS-Messages-in-PHP


Trending Topics: