PHP code example of itexmo / itexmo-sms

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

    

itexmo / itexmo-sms example snippets


use Itexmo\ItexmoSms\ItexmoSms;

$itexmo = app(ItexmoSms::class);
$recipients = ['number_1_here', 'number_2_here']; 
$message = 'Hello from Itexmo!';

$response = $itexmo->broadcast($recipients, $message);

if ($response['success']) {
    echo "SMS sent successfully!";
} else {
    echo "SMS sending failed: " . $response['message'];
}

$itexmo = app(ItexmoSms::class);
$response = $itexmo->checkBalance();

if ($response['success']) {
    echo "Your balance is: " . $response['data']['Balance'];
} else {
    echo "Failed to check balance: " . $response['message'];
}

$recipients = ['number_1_here', 'number_2_here'];
$message = 'Your OTP is 123456.';

$response = $itexmo->broadcastOTP($recipients, $message);

if ($response['success']) {
    echo "OTP sent successfully!";
} else {
    echo "Failed to send OTP: " . $response['message'];
}

$messages = [
    ['number_1_here', 'Hello John!'],
    ['number_2_here', 'Hello Jane!']
];

$response = $itexmo->broadcast2d($messages);

if ($response['success']) {
    echo "Messages sent successfully!";
} else {
    echo "Failed to send messages: " . $response['message'];
}

     $itexmo->broadcast(['number_1_here', 'number_2_here'], 'Hello!');
     

     $itexmo->checkBalance();
     

     $itexmo->broadcastOTP(['number_1_here', 'number_2_here'], 'Your OTP is 123456');
     

     $messages = [
         ['number_1_here', 'Hello John!'],
         ['number_2_here', 'Hello Jane!']
     ];
     $itexmo->broadcast2d($messages);
     

$response = $itexmo->broadcast(['number_1_here'], 'Test message');

if ($response['success']) {
    echo "SMS sent!";
} else {
    echo "Error: " . $response['message'];
}

use Illuminate\Http\Request;
use Itexmo\ItexmoSms\ItexmoSms;

Route::post('/send-sms', function (Request $request) {
    $itexmo = app(ItexmoSms::class);
    $recipients = $request->input('recipients'); // an array of phone numbers
    $message = $request->input('message');

    $response = $itexmo->broadcast($recipients, $message);

    return response()->json($response);
});
bash
php artisan vendor:publish --tag=itexmo-config