PHPackages                             smscx/smscx-api-php-library - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. smscx/smscx-api-php-library

ActiveLibrary[HTTP &amp; Networking](/categories/http)

smscx/smscx-api-php-library
===========================

Client for SMS.CX API

0.1.0(3y ago)06Apache-2.0PHPPHP ^7.4 || ^8.0

Since Oct 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/smscx/smscx-api-php-library)[ Packagist](https://packagist.org/packages/smscx/smscx-api-php-library)[ Docs](https://sms.cx)[ RSS](/packages/smscx-smscx-api-php-library/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (2)Used By (0)

smscx-api-php-library
=====================

[](#smscx-api-php-library)

[![SMS Connexion + PHP logo](https://camo.githubusercontent.com/2a15f643d7fef2010f7ae57cdaa9d999b4476cee2e12dc0ea21e4349aadb7ddd/68747470733a2f2f736d732e63782f6173736574732f696d672f736d732d636f6e6e6578696f6e2d6c6f676f2d736d7363782d78322e706e67)](https://sms.cx)

The SMS Connexion API PHP library provides convenient access to the SMS API of SMS.CX from applications written in the PHP language.

Using this library you can:

- send SMS (transactional, promotional) - single or bulk SMS
- receive SMS
- rent phone numbers
- validate phone numbers
- lookup phone numbers (HLR)
- send OTP SMS (2FA)
- create groups of contacts
- import contacts
- create short links
- and more

For more information, please visit

Content:

- [Installation](#installation)
- [Authentication](#authentication)
- [Usage](#usage)
- [Handling errors](#handling-errors)
- [Rate limit](#rate-limit)
- [Documentation](#documentation)
- [Available methods](#available-methods)

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

[](#installation)

### Requirements

[](#requirements)

PHP 7.4 and later (works with PHP 8.0).

### Composer

[](#composer)

To install the library it is recommended that you use [Composer](https://getcomposer.org/):

```
$ composer require smscx/smscx-api-php-library
```

The above command will install the library and all required dependencies.

To use the library, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):

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

Dependencies
------------

[](#dependencies)

The library require the following extensions in order to work properly:

- [`ext-curl`](https://secure.php.net/manual/en/book.curl.php)
- [`ext-json`](https://secure.php.net/manual/en/book.json.php)
- [`ext-mbstring`](https://www.php.net/manual/en/book.mbstring.php)
- [`Guzzle`](https://github.com/guzzle/guzzle) (PHP HTTP client that makes it easy to send HTTP requests )
- [`GuzzleHttp\Psr7`](https://github.com/guzzle/psr7) (PSR-7 interface for requests, responses, and streams)

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

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

[](#authentication)

To use the library you must authenticate. SMS.CX PHP Library supports the authentication methods supported by the SMS Connexion API:

- [API Key](#1-api-key)
- [Oauth2 Access Token](#2-oauth2-access-token)

### 1. API Key

[](#1-api-key)

To create a new API Key go to [SMS.CX Account &gt; HTTP API &gt; API Keys](https://account.sms.cx/) and click on **New API Key**.

[![Create new API KEY from SMS.CX Dashboard](https://camo.githubusercontent.com/f3101c27e0273b485c069467d124c010fab5985200f55059adda870786e20c72/68747470733a2f2f736d732e63782f6173736574732f696d672f646f63732f64617368626f6172642d6170696b6579732e706e67)](https://camo.githubusercontent.com/f3101c27e0273b485c069467d124c010fab5985200f55059adda870786e20c72/68747470733a2f2f736d732e63782f6173736574732f696d672f646f63732f64617368626f6172642d6170696b6579732e706e67)

Copy the API Key and use it in the library.

### 2. Oauth2 Access Token

[](#2-oauth2-access-token)

Access tokens are used by applications to make API requests.

To create a new application go to [SMS.CX Account &gt; HTTP API &gt; Applications](https://account.sms.cx/) and click on **New Application**.

When you have the Application ID and Application Secret, you can use them to request an access token that you can use to make API calls.

[![Create new application from SMS.CX Dashboard](https://camo.githubusercontent.com/ef0afa57cf81cda6ae9d82c48459f680599b45106d1c716fb502e8c9cdd1d4a8/68747470733a2f2f736d732e63782f6173736574732f696d672f646f63732f64617368626f6172642d746f6b656e732e706e67)](https://camo.githubusercontent.com/ef0afa57cf81cda6ae9d82c48459f680599b45106d1c716fb502e8c9cdd1d4a8/68747470733a2f2f736d732e63782f6173736574732f696d672f646f63732f64617368626f6172642d746f6b656e732e706e67)

Copy the `APPLICATION_ID` and `APPLICATION_SECRET` and use them to request an access token:

```
