PHP code example of durranilab / httpsms

1. Go to this page and download the library: Download durranilab/httpsms 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/ */

    

durranilab / httpsms example snippets




return [
    // HTTP METHOD (get/post)
    'method' => 'get',
    //SMS URL (FOR SENDING SMS)
    'sms_url' => 'http://www.alots.in/sms-panel/api/http/index.php',
    'sms_params' => [
        'username' => 'API_USER_NAME',
        'apikey' => 'API_KEY_OR_PASSWORD',
        'CUSTOM_FIELD_3' => 'ANY_INFO',
    ],
    //BALANCE CHECK URL (FOR SENDING SMS)
    'balance_url' => 'http://www.alots.in/sms-panel/api/http/index.php',
    'balance_params' => [
        'username' => 'API_USER_NAME',
        'apikey' => 'API_KEY_OR_PASSWORD',
        'ANY_QUERY' => 'ANY_QUERY',
        'route' => 'TRANS',
        'format' => 'JSON,TEXT',
    ],

];


use Durranilab\Httpsms\Facades\HttpSMS; 

...

// WHEN ALL PARAMETERS ARE SET IN CONFIG FILE USE
$balanceResponse = HttpSMS::getBalance();
// OR TO USE PARAMETERS IN METHOD
$balanceResponse = HttpSMS::getBalance(
                    ['username'=>'durranilab',
                    'password'=>'YOURPASSWORD',
                    ]);

//TO SEND SMS
$phone = "9764000000,9764123456,...";
$msg = "SMS \n TEXT ";

// WHEN ALL PARAMETERS ARE SET IN CONFIG FILE USE
$smsResponse = HttpSMS::sendMessage();
// OR TO USE PARAMETERS IN METHOD
$smsResponse = HttpSMS::sendMessage([
                   'TemplateID' => '1234567890',
                   'message' => $msg,
                   'mobile' => $phone]);


use Durranilab\Httpsms\HttpSMS;
...

$smsProvider = new HttpSMS();

$balanceResponse = $smsProvider->getBalance();
$smsResponse = $smsProvider->sendMessage();
//OR
$balanceResponse = $smsProvider->getBalance(['username'=>'user123']);
$smsResponse = $smsProvider->sendMessage(['username'=>'user123']);
shell script
php artisan vendor:publish --tag=sms-config