Download the PHP package settermjd/twilio-eventstreams-webhook-validator-slim without Composer
On this page you can find all versions of the php package settermjd/twilio-eventstreams-webhook-validator-slim. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download settermjd/twilio-eventstreams-webhook-validator-slim
More information about settermjd/twilio-eventstreams-webhook-validator-slim
Files in settermjd/twilio-eventstreams-webhook-validator-slim
Package twilio-eventstreams-webhook-validator-slim
Short Description Slim middleware for validating Twilio Event Streams Webhooks
License BSD-3-Clause
Informations about the package twilio-eventstreams-webhook-validator-slim
Slim v4 Twilio Event Streams Webhook Validator Middleware
This is a small piece of middleware for the Slim Framework (v4) that validates a Twilio Event Streams Webhook.
How Does It Work?
After adding the middleware to one or more of your application's routes, when a route is dispatched, the webhook is validated. If the webhook is valid, the next request is called. Otherwise, an HTTP 400 Bad Request is returned, along with a problem details response, formatted as JSON or XML based on the request's Accept header.
Why Use It?
You could code up the functionality yourself; and check out the tutorial on the Twilio blog if you'd like to. But, this middleware avoids the need to do so. Instead, just initialise it and add it to the relevant routes, then focus on the remaining functionality of your application.
Prerequisites
To use this middleware, you're going to need a Twilio account (either free or paid). If you are new to Twilio, create a free account.
⚡️ Quick Start
To use the middleware in your Slim (v4) application, first add the project as a dependency by running the following command:
Then, in the appropriate part of your application, initialise a new EventStreams\EventStreamsWebhookValidatorMiddleware
object, which requires three parameters:
- The application's public URI. During development you could use ngrok to expose the application to the public internet and generate the public URI.
- The webhook URI's path
- A
\Twilio\Security\RequestValidator
object, initialised with your Twilio Auth Token
Note: The first two parameters to EventStreamsWebhookValidatorMiddleware
ensure that the app's correct public URI is used as part of the webhook validation process.
Then, follow the Slim Middleware documentation to add the middleware to the respective route. Below, you can find examples of adding it as Route Middleware:
Then, replace <<THE APP'S PUBLIC URL>>"
with the public URI of the application, <<THE WEBHOOK PATH>>
with he path of the route that handles the webhook request, and <<YOUR TWILIO AUTH TOKEN>>
with your Twilio Auth Token.
Contributing
If you want to contribute to the project, whether you have found issues with it or just want to improve it, here's how:
- Issues: ask questions and submit your feature requests, bug reports, etc
- Pull requests: send your improvements
Did You Find The Project Useful?
If the project was useful and you want to say thank you and/or support its active development, here's how:
- Add a GitHub Star to the project
- Write an interesting article about the project wherever you blog
All versions of twilio-eventstreams-webhook-validator-slim with dependencies
mezzio/mezzio-problem-details Version ^1.14
psr/http-message Version ^2.0
twilio/sdk Version ^8.3