Skip to content

MessageWay/MessageWayPHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

messageWay

Latest Version on Packagist Total Downloads Swagger MessageWay

MessageWay PHP SDK

A PHP SDK for the MessageWay API. (فارسی 🇮🇷)

Available Methods

  • SMS (Iran: 2000, 3000, 9000, 50004)
  • Global SMS (with Twilio)
  • Messenger
  • IVR

Requirements

  • PHP 7.4 or higher
  • ext-curl
  • ext-json
  • composer

Installation

with Composer

$ composer require messageway/messagewayphp

Require

require dirname(__FILE__) . '/../vendor/autoload.php';
use MessageWay\Api\MessageWayAPI;

// Get apiKey from https://MSGWay.com/dashboard/document/
$apiKey = "";
$mobile = "";
$templateID = 3;
$messageWay = new MessageWayAPI($apiKey);

without Composer

$ git clone git@github.com:MessageWay/MessageWayPHP.git

Require

require dirname(__FILE__) . '/MessageWayPHP/src/MessageWayAPI.php';
use MessageWay\Api\MessageWayAPI;

// Get apiKey from https://MSGWay.com/dashboard/document/
$apiKey = "";
$mobile = "";
$templateID = 3;
$messageWay = new MessageWayAPI($apiKey);

Send OTP

By SMS

try {
	$otp = $messageWay->sendViaSMS($mobile, $templateID);
	echo "referenceID: " . $otp['referenceID'] . PHP_EOL;
	echo "sender: " . $otp['sender'] . PHP_EOL;
} catch (Exception $e) {
	echo "Error: " . $e->getMessage();
}

By Messenger

try {
	$provider = $messageWay->getProviderByName('gap');
	$otp = $messageWay->sendViaMessenger($mobile, $templateID, $provider);
	echo "referenceID: " . $otp['referenceID'] . PHP_EOL;
	echo "sender: " . $otp['sender'] . PHP_EOL;
} catch (Exception $e) {
	echo "Error: " . $e->getMessage();
}

By IVR

$templateID = 2;
try {
	$otp = $messageWay->sendViaIVR($mobile, $templateID);
	echo "referenceID: " . $otp['referenceID'] . PHP_EOL;
	echo "sender: " . $otp['sender'] . PHP_EOL;
} catch (Exception $e) {
	echo "Error: " . $e->getMessage();
}

Verify

try {
	$verify = $messageWay->verifyOTP($OTP, $mobile);
	echo "OTPVerify: " . $verify['status'] . PHP_EOL;
} catch (Exception $e) {
	echo "Error: " . $e->getMessage();
}

Status

try {
	$status = $messageWay->getStatus($OTPRefrenceID);
    echo "OTPStatus: " . $status['OTPStatus'] . PHP_EOL;
	echo "OTPVerified: " . $status['OTPVerified'] . PHP_EOL;
	echo "OTPMethod: " . $status['OTPMethod'] . PHP_EOL;
} catch (Exception $e) {
	echo "Error: " . $e->getMessage();
}

Balance

try {
	$balance = $messageWay->getBalance();
    echo "Balance: " . $balance;
} catch (Exception $e) {
	echo "Error: " . $e->getMessage();
}

Get Template

$templateID = 2;
try {
	$template = $messageWay->getTemplate($templateID);
	echo "Template: " . $template['template'] . PHP_EOL;
	echo "Params: " . implode(", ", $template['params']) . PHP_EOL;
} catch (Exception $e) {
	echo "Error: " . $e->getMessage();
}

License

MIT

About

MSGway.com php sdk

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages