bluedogtraining / guzzle-clickatell
A Guzzle client for interacting with the Clickatell API
Installs: 16 934
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 10
Forks: 4
Open Issues: 1
Requires
- guzzle/guzzle: >=3.0,<3.8
Requires (Dev)
README
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
.