PHP code example of advanta_africa / sms_api

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

    

advanta_africa / sms_api example snippets


use AdvantaAfrica\SmsApi\SmsApi;

// Create an instance for sending SMS, OTP, and getting balance or delivery reports
$smsApi = new SmsApi('endpoint', 'apiKey', 'partnerId', 'senderId');

$response = $smsApi->sendSingleSmsPost('07xxxxxxxxxx,07xxxxxxxxx', 'Your message here', 'timeToSend', null);

$response = $smsApi->sendSingleSmsGet('07xxxxxxxxxxx', 'Your message here','timeToSend', null);

$response = $smsApi->sendSingleSmsPost('xxxxxxxxx', 'Your message here', 'timeToSend', 'true');

$response = $smsApi->sendSingleSmsPost('07xxxxxxxxxx', 'Your message here', 'timeToSend',null);

$response = $smsApi->sendSingleSmsGet('xxxxxxxxxx', 'Your message here', 'Your message here', 'true');

$response = $smsApi->sendSingleSmsGet('07xxxxxxxxxx', 'Your message here', 'Your message here',null);

$smsList = [
    [
        'partnerID' => '12345',
        'apikey' => 'apiKey',
        'mobile' => '07xxxxxxxxxxxx',
        'message' => 'This is a test message',
        'shortcode' => 'xxxxxxxxxxxx'
    },
    [
        'partnerID' => '12346',
        'apikey' => 'apiKey',
        'mobile' => '07xxxxxxxxxxxx',
        'message' => 'This is a test message 2',
        'shortcode' => 'xxxxxxxxxxxx'
    ]
];

$response = $smsApi->sendBulkSms($smsList);

$balanceResponse = $smsApi->getBalancePost(); 

$balanceResponse = $smsApi->getBalanceGet();

$deliveryResponse = $smsApi->getDeliveryStatusPost('messageId');

$deliveryResponse = $smsApi->getDeliveryStatusGet('messageId');