PHPackages                             weezqyd/africastalking - 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. weezqyd/africastalking

ActiveLibrary[API Development](/categories/api)

weezqyd/africastalking
======================

PHP Api gateway for AfricasTalking

v1.1.0(8y ago)261911mitPHP

Since Jul 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/weezqyd/africas-talking)[ Packagist](https://packagist.org/packages/weezqyd/africastalking)[ RSS](/packages/weezqyd-africastalking/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (1)

Geting Started
--------------

[](#geting-started)

Install the package from composer

```
$ composer require weezqyd/africastalking @dev
```

You then need to install **one** of the following: But we recomend GuzzleHttp

```
$ composer require guzzlehttp/guzzle
$ composer require kriswallsmith/buzz
$ composer require nategood/httpful
```

Configure the Adapter
---------------------

[](#configure-the-adapter)

This package uses guzzlehttp as the default adapter, if you decide to use another http client good for you all you need is to configure your client and pass the adapter as the fourth parameter to the gateway's constructor. You can also create your own adapter as long as it implements `Http\Adapter\AdapterInterface`.

An example is worth a thousand words

```
require_once 'vendor/autoload.php';

use AfricasTalking\Gateway;
use Http\Adapter\BuzzAdapter;

// These Headers are required
$headers = [
        'apikey' => 'API-KEY',
        'Accept' => 'application/json',
        'Content-Type' => 'application/x-www-form-urlencoded',
    ];
$adapter = new BuzzAdapter($headers);
// Pass the adapter and your Africastalking Username to the gateway
// The third parameter is a sandbox flag when true the Api wiil run in the sandbox, The defaults is false
// Because we are using a custom client you dont need provide the API KEY to the gateway
// Instead pass an empty string or null
$gateway = new Gateway('USERNAME', null, true, $adapter);

```

### Sending an SMS Message

[](#sending-an-sms-message)

Now let us send an SMS notification

```
use AfricasTalking\Gateway;
use Http\Exceptions\HttpException;

$gateway = new Gateway('API-TOKEN', 'USERNAME');
try {
	$response = $gateway->sms->sendMessage('+254700123XXX', 'My sample message');
	var_dump($response);
} catch(HttpException $e) {
	print_r($e);
}
```

#### Passing additional options

[](#passing-additional-options)

The SMS API accept additional options to be passed allong with the request

ParameterDescriptionfromShortcode or alphanumeric that is registered with your Africa's Talking account. If missing, the default value (20414) will be populated on the messageenqueueThis parameter is used for Bulk SMS clients that would like deliver as many messages to the API before waiting for an Ack from the Telcos. If enabled, the API will store the messages in its databases and send them out asynchronously after responding to the requestkeywordThis parameter is used for premium services. It is essential for subscription premium services.linkIdThis parameter is used for premium services to send OnDemand messages. We forward the linkId to your application when the user send a message to your serviceretryDurationInHoursThis parameter is used for premium messages. It specifies the number of hours your subscription message should be retried in case it's not delivered to the subscriber.*Send with options*

```
use Http\Exceptions\HttpException;
// ..... Rest of adapter setup
$options = [
	'from' => '22123',
	'enqueque' => 1
];
try {
	$response = $gateway->sms->sendMessage('+254700123456', 'My sample message', $options);
	var_dump($response);
} catch(HttpException $e) {
	print_r($e);
}
```

#### Sending to multiple recipients

[](#sending-to-multiple-recipients)

At times you would want to do somthing with the API response. Well worry no more. To acheive this pass a callback funtion as the fourth parameter of the `sendMessage()` method. This callback will be run for each message that is sent

```
use Http\Exceptions\HttpException;
// ..... Rest of adapter setup
$recipients = ['+254700123456', '+254700123123', '+254700123000'];
try {
	$gateway->sms->sendMessage($recipients, 'My sample message', ['from' => '22123'], funtion($recipient) {
		// $recipient->status;
		// $recipient->messageId;
		// $recipient->cost;
		// $recipient->number;
	});
} catch(HttpException $e) {
	print_r($e);
}
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~243 days

Total

2

Last Release

2984d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e96a8fb006579076bb41b7d543654038bb9ea28addeb9ac685daee5011195eb3?d=identicon)[weezqyd](/maintainers/weezqyd)

---

Top Contributors

[![weezqyd](https://avatars.githubusercontent.com/u/11520842?v=4)](https://github.com/weezqyd "weezqyd (29 commits)")

---

Tags

africastalkingapiphpsms

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/weezqyd-africastalking/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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