Download the PHP package nickdnk/gatewayapi-php without Composer
On this page you can find all versions of the php package nickdnk/gatewayapi-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nickdnk/gatewayapi-php
More information about nickdnk/gatewayapi-php
Files in nickdnk/gatewayapi-php
Package gatewayapi-php
Short Description PHP library based on Guzzle for integration with gatewayapi.com
License mit
Informations about the package gatewayapi-php
GatewayAPI PHP Library
This library will allow you to integrate the GatewayAPI.com API in your project using modern PHP7 and an OOP structure. For full description of their API, error codes and so on, see: https://gatewayapi.com/docs.
Prerequisites
You need an active account at https://www.gatewayapi.com to use this library. Once you have that you need to generate an API key/secret pair under API -> API Keys.
Installation
To include this in your project, install it using Composer.
This library requires PHP >= 7.1 and works on 8.0, 8.1 and 8.2.
composer require nickdnk/gatewayapi-php
How to use
Example #1: Sending SMS
Example #2: Canceling scheduled messages
You can cancel a scheduled SMS based on the ID returned when sending.
As this method creates a pool of requests (1 per message ID) it does
not throw exceptions but returns an array of CancelResult
. Each of
these contain the status and (if failed) exception of the request.
Example #3: Parsing webhooks
You can easily parse webhooks sent from GatewayAPI to your server
using the Webhook
class. This uses the JWT header to ensure that
the webhook has not been tampered with and is in fact coming from
a trusted source.
To set up webhooks go to API -> Web Hooks -> REST. Specify a JWT secret under Authentication after you've created the webhook.
Two types of webhooks can be sent; delivery status notifications and
incoming messages (MO traffic). Both are parsed by Webhook
and
returned as their corresponding class. To read incoming messages you have to
subscribe to a keyword or number under Subscriptions -> Keywords / Numbers
and assign the keyword or number to a webhook.
Example #4: Handling SMSMessages or Recipients as JSON
SMSMessage
and Recipient
are encoded into the the actual JSON sent
to the API. If you put this output into a queue, or anything similar,
and want them back as PHP objects later, you can use these methods to
do so.
Tests
If you want to run the unit tests that don't require credentials, simply
run vendor/bin/phpunit
from the root of the project.
If you want to test the parts that interact with the API you must
provide credentials in GatewayAPIHandlerTest.php
and run the above
command. Note that this sends out live SMS and will cost you 1 SMS in
credits per execution.
Contact
You can reach me at [email protected].
Use this library at your own risk. PRs are welcome :)
All versions of gatewayapi-php with dependencies
ext-json Version *
guzzlehttp/guzzle Version ^6.0 || ^7.0
guzzlehttp/oauth-subscriber Version 0.3.* || 0.4.* || 0.5.* || 0.6.*