A PHP SDK for the MessageWay API. (فارسی 🇮🇷)
- SMS (Iran: 2000, 3000, 9000, 50004)
- Global SMS (with Twilio)
- Messenger
- IVR
- PHP 7.4 or higher
- ext-curl
- ext-json
- composer
$ composer require messageway/messagewayphp
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);
$ git clone git@github.com:MessageWay/MessageWayPHP.git
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);
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();
}
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();
}
$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();
}
try {
$verify = $messageWay->verifyOTP($OTP, $mobile);
echo "OTPVerify: " . $verify['status'] . PHP_EOL;
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
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();
}
try {
$balance = $messageWay->getBalance();
echo "Balance: " . $balance;
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}
$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();
}
MIT