PHP code example of trez-sms / new-raygan-sms

1. Go to this page and download the library: Download trez-sms/new-raygan-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/ */

    

trez-sms / new-raygan-sms example snippets


$user_name = '*******';
$password = '*******';
$phone_number = '*******';;
$sms = new \Trez\RayganSms\Sms($user_name,$password,$phone_number);

echo $sms->sendMessage('0936*******','Test Message');

echo $sms->sendAuthCode('0936*******');
...
echo $sms->sendAuthCode('0936*******', 'Send From ...');
...
echo $sms->sendAuthCode('0936*******', 'Your Auth Code: 12346', false);

$result = $sms->checkAuthCode('0936*******','922387');
if($result){
    ///
}else{
    ///
}

// .env
...
RAYGANSMS_USERNAME=*******
RAYGANSMS_PASSWORD=*******
RAYGANSMS_PHONE_NUMBER=*******
...

// config/services.php
...
    'raygansms' => [
        'user_name' => env('RAYGANSMS_USERNAME'),
        'password' => env('RAYGANSMS_PASSWORD'),
        'phone_number' => env('RAYGANSMS_PHONE_NUMBER'),
    ],
...

// config/app.php
...
Trez\RayganSms\RayganSmsServiceProvider::class,
...
'RayganSms' => Trez\RayganSms\Facades\RayganSms::class
...

echo  RayganSms::sendMessage('0936*******','Test Message');
    ...   
    
echo  RayganSms::sendAuthCode('0936*******','Welcome ...');
    ...
    
$result = RayganSms::checkAuthCode('0936*******','922387');
if($result){
    ///
}else{
   ///
}
    ...   
    
echo  RayganSms::sendAuthCode('0936*******', 'Your Auth Code: 123456', false);
    ...