bluedogtraining/guzzle-clickatell

A Guzzle client for interacting with the Clickatell API

v2.0.5 2015-05-12 00:08 UTC

This package is not auto-updated.

Last update: 2024-12-18 12:10:58 UTC


README

Build Status

A PHP 5.3+ client for interacting with the Clickatell HTTP API.

Installation

Add this to your composer.json by running composer.phar require bluedogtraining/guzzle-clickatell.

Usage

Create API client

$client = \Bdt\Clickatell\ClickatellClient::factory(array(
    'api_id'   => $apiId,
    'user'     => $user,
    'password' => $password,
));

Authenticate to the API

$client->getCommand('Auth')->execute()->getSessionId();

Ping the API to keep the session ID alive

$client->getCommand('Ping', array('session_id' => $sessionId))->execute();

Send a message

Passing a session_id parameter is optional. If it isn't present the client will use the authentication details provided.

$result = $client->getCommand('SendMsg', array(
    'to'   => $mobileNumber,
    'text' => $messageContents,
))->execute();

$result->isSuccessful();  // true
$result->getMessageIds(); // array('mobile_number' => 'message_id')

A quicker way to send a message is:

$result = $client->sendMessage($mobileNumber, $messageContents); // true|false

Query a message

$client->getCommand('QueryMsg', array(
    'apimsgid' => $messageId,
))->execute()->getStatus();

Running Tests

First, install PHPUnit with composer.phar install --dev, then run ./vendor/bin/phpunit.

More Reading