1. Go to this page and download the library: Download shabayek/laravel-sms library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shabayek / laravel-sms example snippets
'default' => 'smseg',
namespace App\Sms;
use Shabayek\Sms\Contracts\SmsGatewayContract;
use Shabayek\Sms\Enums\ResponseCode;
class CustomSms implements SmsGatewayContract
{
private $config;
public function __construct(array $config)
{
$this->config = $config;
}
public function send($phone, $message): array
{
// Call your gateway here.
return ['success' => true, 'code' => ResponseCode::Sent, 'message' => ResponseCode::Sent->message(), 'provider' => ['code' => null, 'message' => null]];
}
public function sendOtp($phone)
{
// Return the code you sent, or null when nothing was sent.
return null;
}
public function verify(string $phone, int $otp, $actualOtp = null): bool
{
return $actualOtp !== null && hash_equals((string) $actualOtp, (string) $otp);
}
public function balance()
{
return 0;
}
}
php
SMS_MESSAGE="Your verification code is: {code}"
php
'messages' => [
'sent' => 'Message sent successfully',
'rejected' => 'Message not sent successfully',
'http_error' => 'Message not sent successfully',
'invalid_response' => 'Message not sent successfully',
'disabled' => 'SMS driver is disabled',
],
php
$code = Sms::sendOtp('201000000000');
if ($code === null) {
// not sent: show an error or let the user retry
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.