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


Trending Topics: