Sending messages
Send a normal message
use Shabayek\Sms\Facade\Sms;
$sms = Sms::send('0120000000', 'Hello world');
send() returns an array with a response code. See Response codes.
Send an OTP message
With service normal, the package generates the code and sends it in a regular message built from the message config.
With service otp, SMS EG generates and checks the code itself, while SMS Misr sends a code generated by the package through its OTP endpoint. Victory Link and Ooredoo always behave like normal.
use Shabayek\Sms\Facade\Sms;
$sms = Sms::sendOtp('0120000000');
Verify a phone number
use Shabayek\Sms\Facade\Sms;
$phone = '09121234567'; // phone number
$otp = '123456'; // otp that you sent to phone
$actualOtp = '123456'; // this is the actual otp that you sent to the user
$verify = Sms::verify($phone, $otp, $actualOtp); // third param is optional only for SMS EG with service otp
See OTP and verification for what sendOtp() returns and which values verify() accepts.
Change the OTP message
Change the OTP message with SMS_MESSAGE (or message in config/sms.php). Use {code} where the code goes. The message can be in any language: the encoding sent to the gateway (English, Arabic or Unicode) is detected from the text.
SMS_MESSAGE="Your verification code is: {code}"
Use another connection
The Sms facade uses the default connection. To use another connection from config/sms.php, resolve it by name:
use Shabayek\Sms\Facade\Sms;
Sms::driver('smsmisr')->send('0120000000', 'Hello world');