PHPackages                             oxemis/oxisms - 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. oxemis/oxisms

ActiveLibrary[API Development](/categories/api)

oxemis/oxisms
=============

PHP wrapper for the OxiSMS API

v1.0.2(5mo ago)383↓75%MITPHP

Since Apr 17Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/oxemis/oxisms-php)[ Packagist](https://packagist.org/packages/oxemis/oxisms)[ RSS](/packages/oxemis-oxisms/feed)WikiDiscussions main Synced 1mo ago

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

Official OxiSMS PHP Wrapper
===========================

[](#official-oxisms-php-wrapper)

[![MIT License](https://camo.githubusercontent.com/48593de0035d3aebc555d81be22bb1136d0741866cc69614fd437cacc7553cf7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3030374543372e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/48593de0035d3aebc555d81be22bb1136d0741866cc69614fd437cacc7553cf7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3030374543372e7376673f7374796c653d666c61742d737175617265)[![Current Version](https://camo.githubusercontent.com/97f85f046265623c4b26076add9bcc55f9608152c20e78f07076369977c77d05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e302e302d677265656e2e737667)](https://camo.githubusercontent.com/97f85f046265623c4b26076add9bcc55f9608152c20e78f07076369977c77d05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e302e302d677265656e2e737667)

Overview
--------

[](#overview)

This repository contains the official PHP wrapper for the OxiSMS API. To get started, create an account and request your free credits on [this page](https://account.oxemis.com/)

This library is a wrapper for the [OxiSMS API](https://api.oxisms.com) but you don't have to know how to use the API to get started with this library.

What is OxiSMS ?
----------------

[](#what-is-oxisms-)

OxiMailing is a solution designed to enable you to **send your SMS quickly and easily**.

We offer worldwide coverage (see [details](https://www.oxemis.com/en/sms/worldwide-coverage)) and sender personalization when authorized by recipient operators.

All our SMS messages are sent via **Premium routes**, guaranteeing the best possible deliverability.

We're a small team, but we're recognized for the quality of our support and expertise.

Table of contents
-----------------

[](#table-of-contents)

- [Compatibility](#compatibility)
- [Installation](#installation)
- [Authentication](#authentication)
- [Getting information about your account](#getting-information-about-your-account)
- [Sending your first sms](#sending-your-first-sms)
- [How to send customized messages ?](#how-to-send-customized-messages)
- [Using a custom sender](#using-a-custom-sender)
- [How many characters can I put in my message ?](#how-many-characters-can-i-put-in-my-message-)
- [How to get the number of credits that will be used for a sending ?](#how-to-get-the-number-of-credits-that-will-be-used-for-a-sending-)
- [How to specify a strategy for my sending ?](#how-to-specify-a-strategy-for-my-sending-)
- [Other features](#other-features)
- [Contribute](#contribute)

Compatibility
-------------

[](#compatibility)

This library requires **PHP v7.4** or higher.

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

[](#installation)

Use the below code to install the wrapper:

`composer require oxemis/oxisms`

Authentication
--------------

[](#authentication)

This library is a wrapper to the [OxiSMS API](https://api.oxisms.com). You can request an API KEY in your [OxiSMS Account](https://account.oxemis.com). Free credits are offered.

You should export your API\_LOGIN and API\_PASSWORD in order to use them in this library :

```
export OXISMS_API_LOGIN='your API login'
export OXISMS_API_PWD='your API password'
```

Initialize your **OxiSms** Client:

```
require_once 'vendor/autoload.php';
use \Oxemis\OxiSms\OxiSmsClient;

// getenv will allow us to get the OXISMS_API_LOGIN/OXISMS_API_PWD variables we created before:

$apilogin = getenv('OXISMS_API_LOGIN');
$apipwd = getenv('OXISMS_API_PWD');

$oxisms = new OxiSmsClient($apilogin, $apipwd);

// or, without using environment variables:

$apilogin = 'your API login';
$apipwd = 'your API password';

$oxisms = new OxiSmsClient($apilogin, $apipwd);
```

Getting information about your account
--------------------------------------

[](#getting-information-about-your-account)

You will find all the information about your OxiSMS account with the "**UserAPI**" object. Informations returned are documented in the class.

```
require_once "vendor/autoload.php";
use Oxemis\OxiSms\OxiSmsClient;

$client = new OxiSmsClient(API_LOGIN,API_PWD);
$user = $client->userAPI->getUser();

echo "Name :" . $user->getCompanyName() . "\n" .
     "Remaining credits : " . $user->getCredits() . "\n";
```

Sending your first SMS
----------------------

[](#sending-your-first-sms)

In order to send a mail, you must instantiate a `Message` object and, send it, via the `$client->sendAPI->Send()` method.

Here's a simple sample of how to send a SMS :

```
require_once 'vendor/autoload.php';
use Oxemis\OxiSms\OxiSmsClient;
use Oxemis\OxiSms\Objects\Message;

// Create the Client
$apilogin = 'your API login';
$apipwd = 'your API password';
$client = new OxiSmsClient($apilogin, $apipwd);

// Define the message
$message = new Message();
$message
->addRecipientPhoneNumber("+33666666666")
->setMessage("Hi there ! This is my first SMS sent with the awesome oxisms-php library !");

// Send the message
$client->sendAPI->send($message);
```

You can also **schedule a sending** by using the `$message->setScheduledDateTime($selectedDateAndTime)` method.

How to send customized messages?
--------------------------------

[](#how-to-send-customized-messages)

With this library you can send customized messages based on templating. Basically, every content between `{{` and `}}` will be replaced by the corresponding **recipient metadata**.

Here is a simple sample :

```
require_once 'vendor/autoload.php';
use Oxemis\OxiSms\Objects\Recipient;
use Oxemis\OxiSms\Objects\Message;
use Oxemis\OxiSms\OxiSmsClient;

// First of all, we need recipients with meta data
$myFirstRecipient = new Recipient();
$myFirstRecipient->setPhoneNumber("+33666666666");
$myFirstRecipient->setMetaData(["Name" => "Joe", "ID" => 1]);

$mySecondRecipient = new Recipient();
$mySecondRecipient->setPhoneNumber("+3377777777");
$mySecondRecipient->setMetaData(["Name" => "Jane", "ID" => 2]);

// We create the message with {{custom parts}}
$m = new Message();
$m->addRecipient($myFirstRecipient)
->addRecipient($mySecondRecipient)
->setMessage("Hi {{Name}} ! This is your ID : {{ID}}");

// Then we send the two messages in one call !
$client = new OxiSmsClient(API_LOGIN, API_PWD);
$client->sendAPI->send($m);
```

> Two messages will be sent. The first one will be "`Hi Joe ! This is your ID : 1`", the second one : "`Hi Jane ! This is your ID : 2`".

Using a custom sender
---------------------

[](#using-a-custom-sender)

By default, our SMS are sent with a short code (36xxx in France for example) or a specific phone number. But, as we send SMS using **Premium routes**, you can specify a custom sender in your messages.

> Please note that some operators refuse to receive messages with custom senders. In these cases, we'll replace the sender with a short code. You can check the [coverage](https://www.oxemis.com/en/sms/worldwide-coverage) about this.

> Custom senders like **phone numbers are *not allowed*** to prevent spoofing !

The sender **MUST** respect these requirements :

- **2 to 11** characters
- Only ascii **A-Z 0-9 and spaces**

And please not that, **if you use the `commercial` strategy** and a **custom sender**, an unsubscribe method will be added to your message (`STOP SMS 36111` for example). **This can increase the length of the message**.

Ok for you ? So let's set the sender in our previous sample with the `setSender` method:

```
require_once 'vendor/autoload.php';
use Oxemis\OxiSms\OxiSmsClient;
use Oxemis\OxiSms\Objects\Message;

// Define the message
$message = new Message();
$message
->setSender("OxiSMS")
->addRecipientPhoneNumber("+33666666666")
->setMessage("Hi there ! This is my first SMS sent with the awesome oxisms-php library !");

// Send the message
$client = new OxiSmsClient(API_LOGIN, API_PWD);
$client->sendAPI->send($message);
```

How many characters can I put in my message ?
---------------------------------------------

[](#how-many-characters-can-i-put-in-my-message-)

Not an easy answer ! SMS are basically **limited to 160 characters**.

**BUT**, if your message contains **characters that are not in the [GSM alphabet](https://en.wikipedia.org/wiki/GSM_03.38#GSM_8_bit_data_encoding)** (*e.g. emojis or some accented characters like `ê`*) we'll have to send you messages in **unicode** mode. In this case SMS are limited to **70 characters**.

Not enough ? No problem ! Our platform is able to manage **long sms** so that you can send messages **composed by 8 SMS** (it's totaly transparent for your recipients, the parts are concatened). **But in this case SMS are limited to 153 characters (GSM) or 67 characters (Unicode)**.

So, TLDR; :

- If your message contains **only** [GSM characters](https://en.wikipedia.org/wiki/GSM_03.38#GSM_8_bit_data_encoding) the max length of 1 SMS is 160 characters.
- If your message contains **special chars (like emojis)**, the max length of 1 SMS is 70 characters.
- If your message is **GSM and you exceed the 160 chars limit**, the number of SMS used to send the message is : **number of chars / 157** (max 8).
- If your message is **Unicode and you exceed the 70 chars limit**, the number of SMS used to send the message is : **number of chars / 67** (max 8).

How to get the number of credits that will be used for a sending ?
------------------------------------------------------------------

[](#how-to-get-the-number-of-credits-that-will-be-used-for-a-sending-)

As we've seen above, calculate the cost of a sending is not as simple as counting the number of recipients 😁

If you want to get the future cost of a sending, use the `$client->sendAPI->getCostOfMessage($m)` method !

```
// Compute the cost of the message (without sending it !)
$s = $client->sendAPI->getCostOfMessage($message );

// You'll get a Sending structure (without Ids, because messages are not really sent)
echo "This sending will consume " . $s->getTotalCost() . " credit(s).";
```

You can also set a `MaxCreditsPerSending` on your message. If that cost is exceeded, OxiSMS will refuse to send your message.

This example will throw an API Exception :

```
$message = new \Oxemis\OxiSms\Objects\Message();
$message
->setSender("OxiSMS")
->addRecipientPhoneNumber("+33666666666")
->addRecipientPhoneNumber("+33777777777")
->setMaxCreditsPerSending(1)
->setMessage("Hi there ! This is my first SMS sent with the awesome oxisms-php library !");

// Will throw an OxiSmsException :
// Code : 406
// Message : Total credits needed to send the message (2) exceeds the MaxCreditsPerSending parameter (1).
$client->sendAPI->send($message);
```

How to specify a strategy for my sending ?
------------------------------------------

[](#how-to-specify-a-strategy-for-my-sending-)

Strategy is very important for your message.

There are two different stragtegies available :

StrategyMeaningRestrictions**Commecial** (default)Used for **marketing** messages.All sendings in 'commercial' strategy are not allowed in the evening after 9:00 p.m., in the morning before 8:00 a.m. as well as on Sundays and public holidays. **They will not be rejected**, they will be automatically postponed to the next available period.**Notification**Used for **notifications** (password reset, two factors auth...)No restriction> **Please be very careful selecting the strategy.** Sending marketing messages with "Notification" strategy will probably lock your account cause of "complaints" from your recipients !

To specify your strategy, set it in the `Message` :

```
$message = new \Oxemis\OxiSms\Objects\Message();
$message
->setStrategy(Message::STRATEGY_NOTIFICATION)
->addRecipientPhoneNumber("+33666666666")
->setMessage("Here is your code to authenticate : " . $twoFactorsCode);
```

Other features
--------------

[](#other-features)

You'll find a lot of other features by exploring the `*API` objects in the APIClient. Here is a non-exhaustive list of these objects (each one is documented with PHPDoc).

- `blacklistsAPI` : get / set your blacklists (lists of unsubscribed recipients)
- `bouncesAPI` : get / set your bounces (list of invalid phone numbers)
- `sendAPI` : send now or schedule your messages
- `userAPI` : everything about your account

Each object is documented with PHPDoc. Other features will be added in the future. You can also make direct call to the API (and even contribute to this project !). Please take a look at the [API Reference](https://api.oxisms.com) 😀

Contribute
----------

[](#contribute)

Feel free to ask anything, and contribute to this project. Need help ? 👉

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance70

Regular maintenance activity

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.9% 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 ~293 days

Total

3

Last Release

174d ago

### Community

Maintainers

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

---

Top Contributors

[![laudep59](https://avatars.githubusercontent.com/u/98906510?v=4)](https://github.com/laudep59 "laudep59 (10 commits)")[![damienDevOX](https://avatars.githubusercontent.com/u/83002710?v=4)](https://github.com/damienDevOX "damienDevOX (1 commits)")

### Embed Badge

![Health badge](/badges/oxemis-oxisms/health.svg)

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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