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

Lorna Mitchell:
Handling Incoming Webhooks in PHP
Jul 27, 2017 @ 17:27:14

Lorna Mitchell has a quick post to her site sharing a method she uses for handling incoming web hooks requests in PHP and the process her code usually uses for parsing the incoming message.

An increasing number of applications now offer webhooks as an integration, often in addition to an API. The classic example, familiar to most developers, is the GitHub webhooks which can notify your other systems such as CI tooling that a new commit has been added to a branch.

[...] Whether it's your source control, updates from your IoT sensors, or an event coming from another component in your application, I have some Opinions (TM) about handling webhooks, so I thought I'd write them down and include some code as well, since I think this is an area that many applications will need to work with.

She talks about the receive/respond workflow she recommends: immediately storing and acknowledge the data and then responding out of band (asynchronously). She includes a bit of example code that reads in the raw input from the incoming message, saves it and then responds back with a 200 response code back to the waiting service. She then talks about the out-of-band processing the message could use, evaluating the contents and acting on them as a result.

tagged: webhooks incoming processing asynchronous response tutorial

Link: https://lornajane.net/posts/2017/handling-incoming-webhooks-in-php

TutsPlus.com:
Using the Mailgun Store(): A Temporary Mailbox for Your App's Incoming Email
Jun 06, 2016 @ 17:22:39

The TutsPlus.com site has posted a tutorial today showing you how to use the "Store" functionality in Mailgun from your PHP application to temporarily handle your incoming emails.

In today's episode, Mailgun stepped in to sponsor a tutorial about how I integrated its message routing and Store() API to handle replies from users.

For example, when people receive meeting requests from others with Meeting Planner, they may just choose to reply and send a note like they would to a typical email thread. [...] Sounds complicated, but one of Meeting Planner's goals is to reduce the back and forth emails between people about planning and consolidate real-time changes into fewer notifications.

The start by introducing the Mailgun service and, more specifically, the Store() offering it provides. He uses a Yii2 framework based application to show the integration. Once the MX (mail) records are set up correctly it can then hook back in to your mail servers or web application. The code is included to make the migration to hold the notification info, make the POST request back to the application and use background process to handle the mail processing.

tagged: mailgun tutorial store incoming processing temporary callback yii2 example

Link: http://code.tutsplus.com/tutorials/using-the-mailgun-store-a-temporary-mailbox-for-your-apps-incoming-email--cms-26479

SitePoint PHP Blog:
Handle Incoming Email with SendGrid
Aug 27, 2013 @ 15:30:34

On the SitePoint PHP blog today Lukas White has a new tutorial showing you how to handle incoming emails from SendGrid (well, pulled from SendGrid) and translate them into posts for your blog or site.

In this article, I’m going to look at how you might implement an email-to-post feature, using SendGrid. SendGrid is a service for sending email – usually in bulk, but they also offer a less well-publicized feature for handling incoming email. SendGrid can be configured to handle all incoming messages for a given domain by pinging a URI of your choosing, and by implementing a simple webhook, you can act on the incoming mail accordingly.

He bases the simple example off of the Slim framework, creating a structure with a basic database for users and posts. He then goes through the SendGrid interface, pointing out where you add the hostname and URL to call back when a new email comes in. He includes the code to create the callback functionality that accepts the POST request coming from SendGrid. This is then validated and inserted into the database to be pulled out later by the "posts" page. There's also a bit about saving images (or other files) that come in as attachments to the email.

tagged: incoming email sendgrid callback post tutorial image attachment

Link: http://www.sitepoint.com/handle-incoming-email-with-sendgrid/

Lorna Mitchell's Blog:
Accessing Incoming PUT Data from PHP
Jul 31, 2008 @ 17:05:35

For a recent REST web service project, Lorna Mitchell had to put together a server for the remote clients to use. She started with a GET request then moved to handling a POST request then to a PUT request - that's where the difficulty came in:

PHP doesn't have a built-in way to do this, and at first I was a little confused as to how I could reach this information. It turns out that this can be read from the incoming stream to PHP, php://input.

Pulling from that stream gave her the raw data she needed (nicely urlencoded too) that she could parse out and use. She includes a simple example that has a check for the REQUEST_TYPE in the _SERVER superglobal to see how the request should be handled (PUT versus GET).

tagged: put get data incoming rest webservice stream input

Link:

DevShed:
Validating Incoming Data by Using Polymorphism with Objects in PHP 5
Apr 05, 2007 @ 15:56:00

DevShed has posted the final part of their look at using polymorphism with objects in PHP5, this time with a focus on validating incoming data from a form.

In this final installment of the series I'm going to show you how to develop an expandable PHP mechanism for validating different types of incoming data. This will demonstrate how this important pillar of object-oriented programming can be used with a plethora of applications.

They show how to create a simple DataValidator class to act as a base to build from. On top of this, they create classes to validate if the value is:

  • empty
  • an integer
  • if it's numeric
  • if it's in a certain range
  • if it's alphanumeric
  • if it's alphabetic
  • or if it's a valid email address
They also include how to implement these filters, showing a simple Factory pattern that creates the object and runs the value through its validation.

tagged: validation incoming data form polymorphism object php5 validation incoming data form polymorphism object php5

Link:

DevShed:
Validating Incoming Data by Using Polymorphism with Objects in PHP 5
Apr 05, 2007 @ 15:56:00

DevShed has posted the final part of their look at using polymorphism with objects in PHP5, this time with a focus on validating incoming data from a form.

In this final installment of the series I'm going to show you how to develop an expandable PHP mechanism for validating different types of incoming data. This will demonstrate how this important pillar of object-oriented programming can be used with a plethora of applications.

They show how to create a simple DataValidator class to act as a base to build from. On top of this, they create classes to validate if the value is:

  • empty
  • an integer
  • if it's numeric
  • if it's in a certain range
  • if it's alphanumeric
  • if it's alphabetic
  • or if it's a valid email address
They also include how to implement these filters, showing a simple Factory pattern that creates the object and runs the value through its validation.

tagged: validation incoming data form polymorphism object php5 validation incoming data form polymorphism object php5

Link:


Trending Topics: