PHP code example of jamal13647850 / sms-api

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

    

jamal13647850 / sms-api example snippets




use jamal13647850\smsapi\FarazSMS;
use jamal13647850\smsapi\SMS;

// Create a gateway instance (e.g., FarazSMS)
$gateway = new FarazSMS(
    'your_username', 
    'your_password', 
    'your_sender_number'
);

// Create the SMS service with your chosen gateway
$sms = new SMS($gateway);

// Send a simple SMS
$result = $sms->sendSMS('09120000000', 'Hello, this is a test message');

// Check the result
if ($result['status']) {
    echo "SMS sent successfully!";
} else {
    echo "Failed to send SMS. Error: " . print_r($result, true);
}

// Check your account balance
$credit = $sms->getCredit();
echo "Your remaining credit: " . $credit;

$result = $sms->sendSMS('09120000000', 'Your message here');

$numbers = ['09120000000', '09987654321'];
$result = $sms->sendSMS($numbers, 'Your message here');

$parameters = [
    'name' => 'John',
    'code' => '1234'
];
$result = $sms->sendSMSByPattern('09120000000', '', 12345, $parameters);

$credit = $sms->getCredit();

$gateway = new FarazSMS(
    'your_username',
    'your_password',
    'your_sender_number', 
    'https://ippanel.com/services.jspd' // optional URL
);

$gateway = new SMSir(
    'your_api_key',
    'your_sender_number', 
    'https://api.sms.ir/v1/send/' // optional URL
);

$gateway = new FaraPayamak(
    'your_username',
    'your_password',
    'your_sender_number',
    'https://rest.payamak-panel.com/api/SendSMS/' // optional URL
);

$gateway = new Elanak(
    'http://158.58.186.243/webservice/', // optional URL
    'your_username',
    'your_password',
    'your_sender_number'
);

$gateway = new MedianaSMS(
    'your_username',
    'your_password',
    'your_sender_number',
    'https://ippanel.com/services.jspd' // optional URL
);

// Using FarazSMS
$farazGateway = new FarazSMS('username', 'password', 'number');
$sms = new SMS($farazGateway);
$sms->sendSMS('09120000000', 'Test message');

// Switch to SMSir
$smsirGateway = new SMSir('api_key', 'number');
$sms = new SMS($smsirGateway);
$sms->sendSMS('09120000000', 'Test message');

$result = $sms->sendSMS('09120000000', 'Test message');

if ($result['status']) {
    // Success
    $messageId = $result['resultData'];
} else {
    // Error
    $errorCode = $result['resultCode'];
    $errorMessage = $result['resultData'];
}

$result = $sms->sendSMS('09120000000', 'Test message');

// Common fields across all providers
$success = $result['status']; // boolean
$resultCode = $result['resultCode']; // int
$resultData = $result['resultData']; // mixed (can be message ID, array of IDs, etc.)

// Some providers may