PHPackages                             cmtelecom/messaging-php - 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. cmtelecom/messaging-php

Abandoned → [cmdotcom/text-sdk-php](/?search=cmdotcom%2Ftext-sdk-php)Library[API Development](/categories/api)

cmtelecom/messaging-php
=======================

PHP client for integration with the CM platform

v2.0.0(6y ago)513.3k1Apache-2.0PHPPHP &gt;=5.4.0CI failing

Since Jun 7Pushed 6y ago5 watchersCompare

[ Source](https://github.com/CMTelecom/messaging-php)[ Packagist](https://packagist.org/packages/cmtelecom/messaging-php)[ Docs](https://www.cmtelecom.com)[ RSS](/packages/cmtelecom-messaging-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (6)Dependencies (6)Versions (11)Used By (0)

CM Messaging SDK
================

[](#cm-messaging-sdk)

[![Packagist](https://camo.githubusercontent.com/17373932cdd49d30f2fea20e1fc2eb7dcde293a25c527775a765476d0037ead5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f434d54656c65636f6d2f6d6573736167696e672d7068702e737667)](https://packagist.org/packages/cmtelecom/messaging-php)[![Packagist](https://camo.githubusercontent.com/a069739f0c52370c3fc77b208a14ddb21509aec5a49f27d285ec19ee81191c6d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f434d54656c65636f6d2f6d6573736167696e672d7068702e737667)](https://packagist.org/packages/cmtelecom/messaging-php)[![Travis](https://camo.githubusercontent.com/8f31ee3fe93d1111596daaeea9582754de3963e5da93b257cd9ce2b89a0b5d49/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f434d54656c65636f6d2f6d6573736167696e672d7068702e737667)](https://travis-ci.org/CMTelecom/messaging-php)

**Note**: This project is not maintained anymore. Please use  instead.

PHP SDK for easy use of CM messaging services. Built with an easy syntax your SMS, Push and/or Voice messages and send them directly with the CM services.

Simple example
--------------

[](#simple-example)

```
require('vendor/autoload.php');

use GuzzleHttp\Client as GuzzleClient;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;

$message = (new \CM\Messaging\Message())
    ->setFrom('Your name/company name')
    ->setTo(['0031612345678', '0031623456789', '0031634567890'])
    ->setBody('Your message');

try {
    $adapter = new GuzzleAdapter(new GuzzleClient());
    $client  = new \CM\Messaging\Client($adapter, 'your-product-token');
    $result  = $client->send($message);

    if($result->isAccepted()){
        // All messages were accepted
    } else {
        // Not all messages were accepted
    }
} catch (\CM\Messaging\Exception\BadRequestException $e) {
    // The request failed because of an invalid value, all messages has not been send
} catch (\Http\Client\Exception\TransferException $e) {
    // Something unexpected happened
}
```

Requirements
------------

[](#requirements)

- CM account with credits, you can register here .
- Composer installed, or load manually
- PHP &gt;= 7.2

Installation
------------

[](#installation)

Run the following command in the root of your project to add the CM Messaging SDK to your project dependencies:

`composer require cmtelecom/messaging-php`

And

`composer require php-http/guzzle6-adapter`

\*When using an alternative HttpClient you don't have to add the Guzzle adapter dependency but it is recommended to use Guzzle. For advanced usage and other http clients you can look at .

Usage
-----

[](#usage)

Instantiate client with your `product token`, which can be found on the Gateway app when you login to .

```
$client = new \CM\Messaging\Client('your-product-token');
```

### Building a messages

[](#building-a-messages)

To create a message you can use an easy one-liner. The required properties are `from`, `to` and `body`. All others can be set optional.

```
use \CM\Messaging\Settings\AllowedChannel;

$message = (new \CM\Messaging\Message())
       ->setFrom('Your name/company name')
       ->setTo(['0031612345678', '0031623456789', '0031634567890'])
       ->setBody('Message')
       ->setReference('Your message')
       ->setAllowedChannels([AllowedChannel::SMS, AllowedChannel::PUSH, AllowedChannel::VOICE])
       ->setAppKey('your-app-key')
       ->setMinimumNumberOfMessageParts(1)
       ->setMaximumNumberOfMessageParts(8)
       ->setDcs(8);
```

### Sending a message

[](#sending-a-message)

After building a message you can send it as following.

```
$message = (new \CM\Messaging\Message())
        ->setFrom('Your name/company name')
        ->setTo(['0031612345678'])
        ->setBody('Message body');

try {
   $adapter = new GuzzleAdapter(new GuzzleClient());
   $client  = new \CM\Messaging\Client($adapter, 'your-product-token');
   $result  = $client->send($message);
} catch (\CM\Messaging\Exception\BadRequestException $e) {
   // The request failed because of an invalid value, all messages has not been send
} catch (\Http\Client\Exception\TransferException $e) {
   // Something unexpected happened
}
```

### Sending a batch of messages

[](#sending-a-batch-of-messages)

When you send a batch of messages, this is when you have multiple messages with different body's. You can send all of them in one request by making an array of messages. If the body is the same for all recipients you can simply add the array with the recipients phone numbers in the `setTo()`, you won't have to make multiple messages is this case (as shown in the simple example).

```
$message_1 = (new \CM\Messaging\Message())
       ->setFrom('Your name/company name')
       ->setTo(['0031612345678'])
       ->setBody('Message one');
$messages[] = $message_1;

$message_2 = (new \CM\Messaging\Message())
       ->setFrom('Your name/company name')
       ->setTo(['0031623456789', '0031634567890'])
       ->setBody('Message two');
$messages[] = $message_2;

try {
   $adapter = new GuzzleAdapter(new GuzzleClient());
   $client  = new \CM\Messaging\Client($adapter, 'your-product-token');
   $result  = $client->send($messages);
} catch (\CM\Messaging\Exception\BadRequestException $e) {
   // The request failed because of an invalid value, all messages has not been send
} catch (\Http\Client\Exception\TransferException $e) {
   // Something unexpected happened
}
```

### Handle response

[](#handle-response)

After sending a message you get a response back that contains the accepted and failed messages. This way you can validate if the messages are processed as expected. You can do this for all messages or optionally add a phone number or an array of phone numbers to check those specific messages.

```
try {
   $result = $client->send($messages);

   // returns true if all messages are accepted
   $result->isAccepted()

   // returns true if all messages are failed
   $result->isFailed()

   // returns an array with the accepted message responses
   $result->getAccepted()

   // returns an array with the failed message responses
   $result->getFailed()

} catch (\CM\Messaging\Exception\BadRequestException $e) {
   // The request failed because of an invalid value, all messages has not been send

   // Returns body contents of the response with detailed error message(s)
   $contents = $e->getResponse()->getBody()->getContents());
} catch (\Http\Client\Exception\TransferException $e) {
   // Something unexpected happened
}
```

For more detailed error handling you can optionally catch `RequestException`, `HttpException` and/or `NetworkException` which are child's of the more generic `TransferException` exception.

It is also possible to retrieve the PSR-7 response, this can be done with `getResponse()`. The response body content can be retrieved with `getResponse()->getBody()->getContents()`.

### Advanced usage

[](#advanced-usage)

#### Default properties

[](#default-properties)

If you call multiple times the `$client->send()` method and you want certain properties for all messages send in your application you can set these properties on the `$client`. Properties set in the `Message` will still overwrite the properties set in `$client`.

```
$client = (new \CM\Messaging\Client('your-product-token'))
       ->setReference('Your reference')
       ->setAllowedChannels([AllowedChannel::SMS, AllowedChannel::PUSH, AllowedChannel::VOICE])
       ->setAppKey('your-app-key')
       ->setMinimumNumberOfMessageParts(1)
       ->setMaximumNumberOfMessageParts(8)
       ->setDcs(8);
```

#### Strategies

[](#strategies)

By default this SDK will remove duplicate phone numbers within the same message because it is assumed you don't wan't to send the exact same message twice to the same phone number at the same time. If you wan't to disable this strategy/behaviour you can add the following to you `send()` method.

```
$client->send($messages, ['strategy' => ['keep_duplicate_phone_numbers']]);
```

#### Configuration Exceptions

[](#configuration-exceptions)

Exception thrownDescriptionInvalidConfigurationExceptionThe configuration is not valid└ InvalidAllowedChannelExceptionOne or more AllowedChannel(s) is not a valid option└ InvalidStrategyExceptionOne or more stratagie(s) is not a valid option#### Http Exceptions

[](#http-exceptions)

Status codeException thrownDescription**null**TransferExceptionSomething unexpected happened└ **null**RequestExceptionThe request is invalid └ **400-499**HttpExceptionClient-side error └ **400**BadRequestExceptionThe request failed because of an invalid value, all messages has not been send └ **500-599**NetworkExceptionServer-side errorMethods
-------

[](#methods)

### Client

[](#client)

MethodParametersReturn**\_\_construct()**$productToken, HttpClient $httpClientvoid**send()**array/Message $messages, array/null $parametersResponse**getBodyType()**BodyType**setBodyType()**BodyType $bodyType$this**getDcs()**int**setDcs()**int $dcs$this**getReference()**string**setReference()**string $reference$this**getCustomGrouping1()**string**setCustomGrouping1()**string $reference$this**getCustomGrouping2()**string**setCustomGrouping2()**string $reference$this**getCustomGrouping3()**string**setCustomGrouping3()**string $reference$this**getMinimumNumberOfMessageParts()**int**setMinimumNumberOfMessageParts()**int $minimumNumberOfMessageParts$this**getMaximumNumberOfMessageParts()**int**setMaximumNumberOfMessageParts()**int $minimumNumberOfMessageParts$this**getAppKey()**string**setAppKey()**string $appKey$this**getAllowedChannels()**array**setAllowedChannels()**array/AllowedChannel $allowedChannels$this**getProductToken()**string### Message

[](#message)

MethodParametersReturn**getFrom()**array**setFrom()**string $from$this**getTo()**array**setTo()**array/string $to$this**getBody()**string**setBody()**string $body, BodyType/null $bodyType$this**getDcs()**int**setDcs()**int $dcs$this**getReference()**string**setReference()**string $reference$this**getCustomGrouping1()**string**setCustomGrouping1()**string $reference$this**getCustomGrouping2()**string**setCustomGrouping2()**string $reference$this**getCustomGrouping3()**string**setCustomGrouping3()**string $reference$this**getMinimumNumberOfMessageParts()**int**setMinimumNumberOfMessageParts()**int $minimumNumberOfMessageParts$this**getMaximumNumberOfMessageParts()**int**setMaximumNumberOfMessageParts()**int $minimumNumberOfMessageParts$this**getAppKey()**string**setAppKey()**string $appKey$this**getAllowedChannels()**array**setAllowedChannels()**array/AllowedChannel $allowedChannels$this**getProductToken()**string### Response

[](#response)

MethodParametersReturn**getDetails()**string**getAccepted()**array/string/null $phoneNumbersarray /null**isAccepted()**array/string/null $phoneNumbersbool**getFailed()**array/string/null $phoneNumbersarray/null**isFailed()**array/string/null $phoneNumbersbool**getResponse()**PSR-7 ResponseTodo
----

[](#todo)

- Custom grouping support

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~135 days

Recently: every ~210 days

Total

8

Last Release

2365d ago

Major Versions

v1.3.0 → v2.0.02020-01-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1016795?v=4)[Bas Peters](/maintainers/baspeters)[@baspeters](https://github.com/baspeters)

---

Top Contributors

[![tomodutch](https://avatars.githubusercontent.com/u/4613944?v=4)](https://github.com/tomodutch "tomodutch (10 commits)")[![PallieterVerhoeven](https://avatars.githubusercontent.com/u/5493191?v=4)](https://github.com/PallieterVerhoeven "PallieterVerhoeven (4 commits)")[![rojtjo](https://avatars.githubusercontent.com/u/1123887?v=4)](https://github.com/rojtjo "rojtjo (1 commits)")

---

Tags

apisdkpackagelibrarysmscmtelecomcmtelecom

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cmtelecom-messaging-php/health.svg)

```
[![Health](https://phpackages.com/badges/cmtelecom-messaging-php/health.svg)](https://phpackages.com/packages/cmtelecom-messaging-php)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.5k](/packages/aws-aws-sdk-php)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M723](/packages/sylius-sylius)[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

43.2k341.0k1](/packages/ccxt-ccxt)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M151](/packages/algolia-algoliasearch-client-php)[hubspot/api-client

Hubspot API client

24016.2M19](/packages/hubspot-api-client)[php-opencloud/openstack

PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi

2312.4M25](/packages/php-opencloud-openstack)

PHPackages © 2026

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