messageway / messagewayphp
This SDK allows you to connect to MSGWay.com server from your php application.
Installs: 2 727
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: 9.5.x-dev
README
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(); }
License
MIT