baha2odeh/yii2-nexmo

Yii2 nexmo is a wrapper for the Nexmo PHP library. Allow yii2 application to use nexmo services.

Installs: 135

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 2

Type:yii2-extension

2.0 2019-10-10 12:18 UTC

This package is auto-updated.

Last update: 2024-04-14 18:26:52 UTC


README

Nexmo yii2 wrapper. Enable nexmo services in yii2 application.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require dpodium/yii2-nexmo "*"

or add

"dpodium/yii2-nexmo": "*"

to the require section of your composer.json file.

Component Setup

Once the extension is installed, simply modify your application configuration as follows:

return [
    'components' => [
    ...
        'nexmo' => [
                   'class' => dpodium\yii2\Nexmo\NexmoManager::class,
                   'config' => [
                                   'api.key' => API_KEY, //from nexmo
                                   'api.secret' => API_SECRET, //from nexmo
                               ],
                   //leave blank if not applicable
                   'proxy' => [
                                   'host' => HOST,
                                   'port' => PORT,
                               ],
               ],
        ...
    ],
    ...
];

Usage

Sending message
Yii::$app->nexmo->sendSms(TO, FROM, 'Test Nexmo Message');

Receiving A Message
Yii::$app->nexmo->receiveMessage();

Fetching A Message
Yii::$app->nexmo->fetchMessage(MESSAGE_ID);

Starting a Verification
Yii::$app->nexmo->initVerification(NUMBER, BRAND);

Controlling a Verification
Trigger
Yii::$app->nexmo->triggerVerification(REQUEST_ID);
Cancel
Yii::$app->nexmo->cancelVerification(REQUEST_ID);

Checking A Verification
Yii::$app->nexmo->checkVerification(REQUEST_ID, CODE);

Searching For A Verification
Yii::$app->nexmo->searchVerification(REQUEST_ID);