PHP code example of robust-tools / resala

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

    

robust-tools / resala example snippets


return [

    /*
     * You can specify a default service provider driver here.
     * If it is not set we'll use vodafone as the default driver.
     */
    'default' => env('SMS_DRIVER', 'vodafone'),

    /*
    |--------------------------------------------------------------------------
    | List of sms drivers
    |--------------------------------------------------------------------------
    |
    | This is a list of possible sms gateways drivers
    |
    */

    'drivers' => [

        'vodafone' => [
            'end_point' => env('VODAFONE_END_POINT'),
            'account_id' => env('VODAFONE_ACCOUNT_ID'),
            'password' => env('VODAFONE_PASSWORD'),
            'secure_hash' => env('VODAFONE_SECURE_HASH'),
            'sender_name' => env('VODAFONE_SENDER_NAME', 'Vodafone')
        ],

        'connekio' => [
            'single_sms_endpoint' => env('SINGLE_SMS_ENDPOINT'),
            'batch_sms_endpoint' => env('BATCH_SMS_ENDPOINT'),
            'username' => env('CONNEKIO_USERNAME'),
            'password' => env('CONNEKIO_PASSWORD'),
            'account_id' => env('CONNEKIO_ACCOUNT_ID'),
            'sender_name' => env('CONNEKIO_SENDER_NAME')
        ],

        'infobip' => [
            'end_point' => env('INFOBIP_END_POINT'),
            'username' => env('INFOBIP_USERNAME'),
            'password' => env('INFOBIP_PASSWORD'),
            'sender_name' => env('INFOBIP_SENDER_NAME', 'Infobip')
        ],

        'vectory_link' => [
            'end_point' => env('VECTORY_LINK_END_POINT'),
            'username' => env('VECTORY_LINK_USERNAME'),
            'password' => env('VECTORY_LINK_PASSWORD'),
            'sender_name' => env('VECTORY_LINK_SENDER_NAME', 'Vectory Link'),
            'lang' => env('VECTORY_LINK_LANG', 'E')
        ],

        'community_ads' => [
            'end_point' => env('COMMUNITY_ADS_END_POINT', 'https://app.community-ads.com/SendSMSAPI/api/SMSSender/SendSMS'),
            'username' => env('COMMUNITY_ADS_USERNAME'),
            'password' => env('COMMUNITY_ADS_PASSWORD'),
            'sender_name' => env('COMMUNITY_ADS_SENDER_NAME', 'Community Ads'),
            'lang' => env('COMMUNITY_ADS_LANG', 'E')
        ],

        'gateway_sa' => [
            'end_point' => env('GATEWAYSA_END_POINT', 'http://REST.GATEWAY.SA/api/SendSMS'),
            'api_id' => env('GATEWAYSA_API_ID'),
            'api_password' => env('GATEWAYSA_API_PASSWORD'),
            'sms_type' => env('GATEWAYSA_SMS_TYPE', 'T'),
            'encoding' => env('GATEWAYSA_ENCODING', 'T'),
            'sender_id' => env('GATEWAYSA_SENDER_ID'),
            'templateid' => env('GATEWAYSA_TEMPLATE_ID'),
        ],

        'brandencode' => [
            'end_point' => env('BRANDENCODE_END_POINT'),
            'username' => env('BRANDENCODE_USERNAME'),
            'password' => env('BRANDENCODE_PASSWORD'),
            'sender_name' => env('BRANDENCODE_SENDER_NAME', 'Brandencode'),
            'lang' => env('BRANDENCODE_LANG', 'E')
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Class Maps
    |--------------------------------------------------------------------------
    |
    |
    | This is a list of Classes that maps to the Drivers above.
    */
    'map' => [
        'vodafone' => VodafoneDriver::class,
        'connekio' => ConnekioDriver::class,
        'infobip' => InfobipDriver::class,
        'vectory_link' => VectoryLinkDriver::class,
        'community_ads' => CommunityAdsDriver::class,
        'gateway_sa' => GatewaySA::class,
        'brandencode' => BrandEncodeDriver::class
    ],
];

$response = SMS::to(['010xxxxxxxx', '011xxxxxxxx'])
    ->message("Hello World")
    ->send();

$response->success(); // returns bool
$response->body(); // returns string

SMS::via('vodafone')
    ->to('010xxxxxxxx')
    ->message("Hello World")
    ->send();

use RobustTools\Resala\SMS;

$configFile = __DIR__ . "/config/resala.php";

(new SMS($driver, $configFile))->to(['010995162378', '012345522'])
         ->message("Hello World")
         ->send();
bash
php artisan vendor:publish --provider="RobustTools\Resala\SMSServiceProvider" --tag="config"
bash
php artisan resala:make vodafone
bash
php artisan resala:make connekio
bash
php artisan resala:make infobip
bash
php artisan resala:make vectory_link
bash
php artisan resala:make community_ads
bash
php artisan resala:make brandencode
bash
php artisan resala:make gateway_sa