Loader

PHP

 

Overview

Use Clickatell’s PHP script library with our REST messaging APIs to interact with the Clickatell SMS Gateway. The PHP script below allows you to send SMS messages using Clickatell’s SMS Platform. Using PHP, you’ll also be able to set up callbacks/webhooks for outgoing and inbound messages via a RESTful interface.

View on Github

Master: Build/Passing

This library allows integration with the new Clickatell website.

Note: Customers with accounts registered on the old central.clickatell.com should use the tagged released or dev branches for version 2 of the repository since version 3 and up is for the new platform and older accounts will not work.


Usage

The new APIs only support sendMessage call and webhooks for outgoing and inbound messages via a RESTful interface.

use Clickatell\Rest;
use Clickatell\ClickatellException;
 
$clickatell new \Clickatell\Rest('token');
 
try {
    $result $clickatell->sendMessage(['to' => ['27111111111'], 'content' => 'Message Content']);
 
    foreach ($result['messages'as $message) {
        var_dump($message);
 
        /*
        [
            'apiMsgId'  => null|string,
            'accepted'  => boolean,
            'to'        => string,
            'error'     => null|string
        ]
        */
    }
 
catch (ClickatellException $e) {
    // Any API call error will be thrown and should be handled appropriately.
    // The API does not return error codes, so it's best to rely on error descriptions.
    var_dump($e->getMessage());
}

 

Status/reply callback

After configuring your webhooks/callbacks inside the developer portal, you can use the static callback methods to listen for web requests from Clickatell. These callbacks will extract the supported fields from the request body.

use Clickatell\Rest;
use Clickatell\ClickatellException;
 
// Outgoing traffic callbacks (MT callbacks)
Rest::parseStatusCallback(function ($result) {
    var_dump($result);
    // This will execute if the request to the web page contains all the values
    // specified by Clickatell. Requests that omit these values will be ignored.
});
 
// Incoming traffic callbacks (MO/Two Way callbacks)
Rest::parseReplyCallback(function ($result) {
    var_dump($result);
    // This will execute if the request to the web page contains all the values
    // specified by Clickatell. Requests that omit these values will be ignored.
});

 

Issues/Contributions

Found a bug or missing a feature? Log it here and we will take a look.

 

Channels

Find the most up-to-date information about the channels available to communicate with your clients.

SDKs

Documentation
SMS

Enable any application, website or system to facilitate local or international one- or two-way SMS communication via an easy one-step integration with our HTTP API.

Documentation
One API

Communicate with your mobile customers via multiple communication channels with a single integration. You can send and receive messages on both WhatsApp and SMS without the overhead of programming individual channels.

Documentation
WhatsApp

As an authorized WhatsApp Business Solution Provider, we assist you in applying for a WhatsApp Business account and number. Integrate with other powerful features available on our platform via our One API.

Documentation

Products

Find the most up-to-date information about the products we offer and how to elevate your engagement with customers.

Chat 2 Pay

Send payment requests to customers via chat for secure, contactless payment experiences.

Documentation
Chat Desk

An easy-to-use web-based application that enables real-time communication with your customers via a single web interface.

Documentation
Chat Flow

A web-based application that allows you to quickly and collaboratively design and deploy conversational experiences across multiple chat applications and connect it to your organization's core functional APIs.

Documentation
Campaign Manager

An online tool that allows you to create a custom SMS campaign within minutes - no coding or developers required.

Documentation

Marketplace

Find the most up-to-date information about Clickatell's Marketplace and how you can utilize it for the distribution and payment acceptance of digital products.

Bank Interfaces API

An explanation of the way Clickatell and banks interact with one another when dealing with purchases. 

Documentation
Transact Result API

Initiates the delivery of the transaction result for a purchase that was made through Clickatell after Clickatell facilitated the dispensing of the product.

Documentation
Reserve and Transact API

Initiates a purchase and fund reservation request to Clickatell.

Documentation
Security Service API

Request authentication tokens to use in all other Clickatell API calls.

Documentation
Transact

A cloud-based platform that allows for the distribution and payment acceptance of multiple digital products.

Documentation
Product Lookup API

Confirm a product's configuration and attributes.

Documentation
In-Flight Transaction Check API

Used prior to a purchase instruction to confirm that no similar transaction is in progress.

Documentation
User Transaction Lookup API

Identify if a new transaction is similar to one of the user's recent transactions so the response details can be used to pre-emptively complete the current transaction details.

Documentation
Customer Account Validation API

Validate a customer's bill payment account number prior to submitting the bill payment purchase request to the vendor.

Documentation
MNO Lookup API

Derive the specific mobile network operator (MNO) for the specified MSISDN.

Documentation
Token Lookup API

Look up tokens/vouchers to present back to the buyer/customer who purchased token-related products via Clickatell's platform.

Documentation
Notifications API

Send notifications to buyer/recipient using different channels.

Documentation
Transaction Lookup API

Used after a purchase to confirm the transaction status.

Documentation
Financial Terms Lookup API

Display the correct fee and settlement amounts as per the contractual agreement for the SKU being purchased.

Documentation
Transact API

Initiates a purchase request to Clickatell.

Documentation

Other Resources

Ask the Community

Visit Stack Overflow to join our community of developers and find the answer you need

Contact Support

Contact our support team and one of our agents will be in touch with you to answer any questions you have