PHPackages                             rockandscissor/clockworksms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rockandscissor/clockworksms

ActiveLibrary[API Development](/categories/api)

rockandscissor/clockworksms
===========================

ClockworkSMS, International SMS API

2.0.1(4y ago)05MITPHP

Since Nov 30Pushed 4y agoCompare

[ Source](https://github.com/rockandscissor/clockwork-php)[ Packagist](https://packagist.org/packages/rockandscissor/clockworksms)[ RSS](/packages/rockandscissor-clockworksms/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Clockwork SMS API Wrapper for PHP
=================================

[](#clockwork-sms-api-wrapper-for-php)

This wrapper lets you interact with Clockwork without the hassle of having to create any XML or make HTTP calls. This version of the wrapper has been forked and updated to work with newer versions of PHP by Rock &amp; Scissor as Mediaburst was acquired by Textanywhere which means the original repo was abandoned. We intend to keep this package up to date as long as the API is still supported by Textanywhere.

What's Clockwork?
-----------------

[](#whats-clockwork)

[Clockwork](http://www.clockworksms.com/) is Mediaburst's SMS API.

### Prerequisites

[](#prerequisites)

- A [Clockwork](http://www.clockworksms.com/) account

Usage
-----

[](#usage)

### Installing with composer

[](#installing-with-composer)

The easiest way to get Clockwork is to use [Composer](https://getcomposer.org/) to automatically download and include it in your project. Setup [Composer](https://getcomposer.org/) and add us to your composer.json

```
{
    "require": {
        "rockandscissor/clockworksms": "2.0.*"
    }
}
```

If you are using your own autoloader we are using the PSR-4 namespacing scheme.

### Including directly

[](#including-directly)

Download the Clockwork library, put it in your project and require the Clockwork class and the ClockworkException classes:

```
require 'src/Clockwork.php';
require 'src/ClockworkException.php';
```

### Sending a message

[](#sending-a-message)

```
$clockwork = new mediaburst\ClockworkSMS\Clockwork( $API_KEY ); //Be careful not to post your API Keys to public repositories.
$message = array( 'to' => '441234567891', 'message' => 'This is a test!' );
$result = $clockwork->send( $message );
```

### Sending multiple messages

[](#sending-multiple-messages)

We recommend you use batch sizes of 500 messages or fewer. By limiting the batch size it prevents any timeouts when sending.

```
$clockwork = new mediaburst\ClockworkSMS\Clockwork( $API_KEY ); //Be careful not to post your API Keys to public repositories.
$messages = array(
    array( 'to' => '441234567891', 'message' => 'This is a test!' ),
    array( 'to' => '441234567892', 'message' => 'This is a test 2!' )
);
$results = $clockwork->send( $messages );
```

### Handling the response

[](#handling-the-response)

The responses come back as arrays, these contain the unique Clockwork message ID, whether the message worked (`success`), and the original SMS so you can update your database.

```
Array
(
    [id] => VE_164732148
    [success] => 1
    [sms] => Array
        (
            [to] => 441234567891
            [message] => This is a test!
        )

)

```

If you send multiple SMS messages in a single send, you'll get back an array of results, one per SMS.

The result will look something like this:

```
Array
(
    [0] => Array
        (
            [id] => VI_143228951
            [success] => 1
            [sms] => Array
                (
                    [to] => 441234567891
                    [message] => This is a test!
                )

        )

    [1] => Array
        (
            [id] => VI_143228952
            [success] => 1
            [sms] => Array
                (
                    [to] => 441234567892
                    [message] => This is a test 2!
                )

        )

)

```

If a message fails, the reason for failure will be set in `error_code` and `error_message`.

For example, if you send to invalid phone number "abc":

```
Array
(
    [error_code] => 10
    [error_message] => Invalid 'To' Parameter
    [success] => 0
    [sms] => Array
        (
            [to] => abc
            [message] => This is a test!
        )

)

```

### Checking your balance

[](#checking-your-balance)

Check your available SMS balance:

```
$clockwork = new mediaburst\ClockworkSMS\Clockwork( $API_KEY ); //Be careful not to post your API Keys to public repositories.
$clockwork->checkBalance();
```

This will return:

```
Array
(
    [symbol] => £
    [balance] => 351.91
    [code] => GBP
    [account_type] => PAYG
)

```

Account Type can be either PAYG or Invoice.

### Handling Errors

[](#handling-errors)

The Clockwork wrapper will throw a `ClockworkException` if the entire call failed.

```
try
{
    $clockwork = new rockandscissor\ClockworkSMS\Clockwork( 'invalid_key' );
    $message = array( 'to' => 'abc', 'message' => 'This is a test!' );
    $result = $clockwork->send( $message );
}
catch( mediaburst\ClockworkSMS\ClockworkException $e )
{
    print $e->getMessage();
    // Invalid API Key
}
```

### Advanced Usage

[](#advanced-usage)

This class has a few additional features that some users may find useful, if these are not set your account defaults will be used.

### Optional Parameters

[](#optional-parameters)

See the [Clockwork Documentation](http://www.clockworksms.com/doc/clever-stuff/xml-interface/send-sms/) for full details on these options.

- $from \[string\]

    The from address displayed on a phone when they receive a message
- $long \[boolean\]

    Enable long SMS. A standard text can contain 160 characters, a long SMS supports up to 459.
- $truncate \[nullable boolean\]

    Truncate the message payload if it is too long, if this is set to false, the message will fail if it is too long.
- $invalid\_char\_action \[string\]

    What to do if the message contains an invalid character. Possible values are

    - error - Fail the message
    - remove - Remove the invalid characters then send
    - replace - Replace some common invalid characters such as replacing curved quotes with straight quotes
- $ssl \[boolean, default: true\]

    Use SSL when making an HTTP request to the Clockwork API

### Setting Options

[](#setting-options)

#### Global Options

[](#global-options)

Options set on the API object will apply to all SMS messages unless specifically overridden.

In this example both messages will be sent from Clockwork:

```
$options = array( 'from' => 'Clockwork' );
$clockwork = new mediaburst\ClockworkSMS\Clockwork( $API_KEY, $options ); //Be careful not to post your API Keys to public repositories.
$messages = array(
    array( 'to' => '441234567891', 'message' => 'This is a test!' ),
    array( 'to' => '441234567892', 'message' => 'This is a test 2!' )
);
$results = $clockwork->send( $messages );
```

#### Per-message Options

[](#per-message-options)

Set option values individually on each message.

In this example, one message will be from Clockwork and the other from 84433:

```
$clockwork = new mediaburst\ClockworkSMS\Clockwork( $API_KEY, $options ); //Be careful not to post your API Keys to public repositories.
$messages = array(
    array( 'to' => '441234567891', 'message' => 'This is a test!', 'from' => 'Clockwork' ),
    array( 'to' => '441234567892', 'message' => 'This is a test 2!', 'from' => '84433' )
);
$results = $clockwork->send( $messages );
```

### SSL Errors

[](#ssl-errors)

Due to the huge variety of PHP setups out there a small proportion of users may get PHP errors when making API calls due to their SSL configuration.

The errors will generally look something like this:

```
Fatal error:
Uncaught exception 'Exception' with message 'HTTP Error calling Clockwork API
HTTP Status: 0
cURL Erorr: SSL certificate problem, verify that the CA cert is OK.
Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed'

```

If you're seeing this error there are two fixes available, the first is easy, simply disable SSL on Clockwork calls. Alternatively you can setup your PHP install with the correct root certificates.

#### Disable SSL on Clockwork calls

[](#disable-ssl-on-clockwork-calls)

```
$options = array( 'ssl' => false );
$clockwork = new mediaburst\ClockworkSMS\Clockwork( $API_KEY, $options );  //Be careful not to post your API Keys to public repositories.
```

#### Setup SSL root certificates on your server

[](#setup-ssl-root-certificates-on-your-server)

This is much more complicated as it depends on your setup, however there are many guides available online. Try a search term like "windows php curl root certificates" or "ubuntu update root certificates".

License
=======

[](#license)

This project is licensed under the MIT open-source license.

A copy of this license can be found in license.txt.

Contributing
============

[](#contributing)

If you have any feedback on this wrapper drop us an email to .

The project is hosted on GitHub at . If you would like to contribute a bug fix or improvement please fork the project and submit a pull request.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1521 days

Total

2

Last Release

1617d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/908159ddcd7343c0dd703964c5764df19a578d4a8afc3334ef17980b01cabeff?d=identicon)[memattstone](/maintainers/memattstone)

---

Top Contributors

[![jfi](https://avatars.githubusercontent.com/u/663625?v=4)](https://github.com/jfi "jfi (18 commits)")[![MeMattStone](https://avatars.githubusercontent.com/u/1451037?v=4)](https://github.com/MeMattStone "MeMattStone (3 commits)")[![WiseAndy](https://avatars.githubusercontent.com/u/1763933?v=4)](https://github.com/WiseAndy "WiseAndy (3 commits)")

---

Tags

sms

### Embed Badge

![Health badge](/badges/rockandscissor-clockworksms/health.svg)

```
[![Health](https://phpackages.com/badges/rockandscissor-clockworksms/health.svg)](https://phpackages.com/packages/rockandscissor-clockworksms)
```

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k101.1M316](/packages/twilio-sdk)[aloha/twilio

Twilio API for Laravel

4783.8M5](/packages/aloha-twilio)[plivo/plivo-php

A PHP SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML

1143.1M19](/packages/plivo-plivo-php)[plivo/php-sdk

A PHP SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML

1112.0M6](/packages/plivo-php-sdk)[smsapi/php-client

SMSAPI API PHP Client

682.3M19](/packages/smsapi-php-client)[africastalking/africastalking

Official Africa's Talking PHP SDK

122620.2k13](/packages/africastalking-africastalking)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
