2017 © Pedro Peláez

library rest-api-client

Wrapper for SMSGlobal's REST API



Wrapper for SMSGlobal's REST API

  • Friday, February 2, 2018
  • by JasonHendry
  • Repository
  • 8 Watchers
  • 5 Stars
  • 14,951 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 1 Open issues
  • 1 Versions
  • 5 % Grown


DEPRECATED: This library and the REST API v1 has been deprecated. More information at https://hs.smsglobal.com/services-update

SMSGlobal Class Library for PHP

This is a wrapper for the SMSGlobal REST API. Get an API key from SMSGlobal by signing up and viewing the API key page in the MXT platform., (*1)

View the REST API documentation for a list of available resources., (*2)

Quick Start

This wrapper is requires PHP 5.3 or greater, and either the cURL library or the HTTP stream wrapper to be installed and enabled., (*3)

To install, add the dependency to your composer.json file:, (*4)

    "require": {
        "smsglobal/rest-api-client": "*"

And install with Composer., (*5)

$ cd path/to/your/project
$ composer install --no-dev

Not using Composer?

You can install the library by downloading it from Github. Just use a PSR-0 compliant autoloader to load in the classes., (*6)

To run unit tests or generate documentation, you'll need PHPUnit and phpDocumentor., (*7)

Running Unit Tests

$ cd path/to/SMSGlobal/rest/api/client
$ composer install
$ phpunit

Get documentation

Documentation is available on the SMSGlobal website, or you can generate it yourself:, (*8)

$ cd path/to/SMSGlobal/rest/api/client
$ composer install
$ vendor/phpdocumentor/phpdocumentor/bin/phpdoc.php -c phpdoc.xml

Using the library

Running Unit Tests, (*9)

// Include the Composer autoloader or use your own PSR-0 autoloader
require 'vendor/autoload.php';

use Smsglobal\RestApiClient\ApiKey;
use Smsglobal\RestApiClient\Resource\Sms;
use Smsglobal\RestApiClient\RestApiClient;

// Get an API key from SMSGlobal and insert the key and secret
$apiKey = new ApiKey('your-api-key', 'your-api-secret');

// All requests are done via a 'REST API client.' This abstracts away the REST
// API so you can deal with it like you would an ORM
$rest = new RestApiClient($apiKey);

// Now you can get objects
$contact = $rest->get('contact', 1); // Contact resource with ID = 1
// Edit them
// And save them
// Or delete them

// You can also instantiate new resources
$sms = new Sms();
    ->setMessage('Hello World');
// And save them
// When a new object is saved, the ID gets populated (it was null before)
echo $sms->getId(); // integer

// For an SMS, saving also sends the message, so you can use a more meaningful
// keyword for it

// You can get a list of available resources
$list = $rest->getList('sms');

foreach ($list->objects as $resource) {
    // ...

// Pagination data is included
echo $list->meta->getTotalPages(); // integer

// Lists can be filtered
// e.g. contacts belonging to group ID 1
$rest->getList('contact', 0, 20, array('group' => 1));


  1. Requesting the same object twice in one session will return the same instance (even in the resource lists)
  2. Exceptions are thrown if you attempt to save an object with invalid data

The Versions

02/02 2018


9999999-dev http://www.smsglobal.com/

Wrapper for SMSGlobal's REST API

  Sources   Download


The Requires

  • php >=5.3.0


The Development Requires