Send SMS from your application using the Esendex API

Installs: 2 637

Dependents: 1

Stars: 13

Watchers: 42

Forks: 3

Open Issues: 1

Language: PHP

v1.0.6 2014-12-18 09:47 UTC

README

Build Status Latest Stable Version Latest Unstable Version License

Installation

Requirements

  • PHP >= 5.3.0
  • ext-curl enabled

The esendex-php-sdk is available to install through several methods as well as from source.

Composer
{
    "require": {
        "esendex/sdk": "1.0.*"
    }
}

We're in the default Packagist repository so just run

$ php composer.phar require esendex/sdk:1.0.*

or add the snippet above to your composer.json

Then just include the generated autoload.php somewhere in your code;

require_once 'path/to/vendor/autoload.php';
PEAR

Our package requires version 1.9.3 or newer

$ pear config-set auto_discover 1
$ pear install esendex.github.com/pear/Esendex

We provide a PSR-0 autoloader you can use for your convenience;

require_once 'Esendex/autoload.php';
GZIP

Download the current version here

Our autoloader may be included somewhere in your application;

require_once 'path/to/downloaded/Esendex/autoload.php';

Getting Started

Sending SMS
$message = new \Esendex\Model\DispatchMessage(
    "WebApp", // Send from
    "01234567890", // Send to any valid number
    "My Web App is SMS enabled!",
    \Esendex\Model\Message::SmsType
);
$authentication = new \Esendex\Authentication\LoginAuthentication(
    "EX000000", // Your Esendex Account Reference
    "user@example.com", // Your login email address
    "password" // Your password
);
$service = new \Esendex\DispatchService($authentication);
$result = $service->send($message);

print $result->id();
print $result->uri();
Retrieving Inbox Messages
$authentication = new \Esendex\Authentication\LoginAuthentication(
    "EX000000", // Your Esendex Account Reference
    "user@example.com", // Your login email address
    "password" // Your password
);
$service = new \Esendex\InboxService($authentication);

$result = $service->latest();

print "Total Inbox Messages: {$result->totalCount()}";
print "Fetched: {$result->count()}";
foreach ($result as $message) {
    print "Message from: {$message->originator()}, {$message->summary()}";
}
Track Message Status
$authentication = new \Esendex\Authentication\LoginAuthentication(
    "EX000000", // Your Esendex account reference
    "user@example.com", // Your login email
    "password" // Your password
);
$headerService = new \Esendex\MessageHeaderService($authentication);
$message = $headerService->message("messageId");
print_r($message->status());
Retrieving Full Message Body
$messageId = "unique-id-of-message";
$authentication = new \Esendex\Authentication\LoginAuthentication(
    "EX000000", // Your Esendex Account Reference
    "user@example.com", // Your login email address
    "password" // Your password
);
$service = new \Esendex\MessageBodyService($authentication);

$result = $service->getMessageBodyById($messageId);

print $result;

Would you like to know more?

Full REST API documentation can be found @ developers.esendex.com

Testing

Unit Tests

A suite of tests can be found in the test directory. To run them use the phing build utility. e.g.

$ php phing-latest.phar
Credentials Test

You can check your account credentials using a phing task we have provided.

$ php phing-latest.phar check-access
Buildfile: /home/developer/esendex-php-sdk/build.xml

EsendexSDK > install_dependencies:


EsendexSDK > check-access:

Esendex Username ? user@example.com
Esendex Password ? secret
Account Reference? EX000000

    Account credentials OK!

BUILD FINISHED

Total time: 10.0000 seconds

Issues

We hope you don't run into any issues but if you should please make use of the issue tracker on github or send an email to support@esendex.com

Feedback

Let us know what you think @esendex