PHP code example of steevenz / rajasms

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

    

steevenz / rajasms example snippets


use Steevenz\Rajasms;

/*
 * --------------------------------------------------------------
 * Inisiasi Class RajaSMS
 *
 * @param string Username
 * @param string API Key
 * --------------------------------------------------------------
 */
 $rajasms = new Rajasms([
    'serverIp' => '127.0.0.1' // IP yang didapat ketika pendaftaran
    'apiKey => 'API_KEY_ANDA' // Ada pada panel RajaSMS
    'callbackUrl' => 'https://domain.anda/reporting-rajasms', // Callback ke controller reporting anda
    'sendingTime' => null, // Bersifat optional untuk membuat scheduling sms
 ]);

/*
 * --------------------------------------------------------------
 * Melakukan send sms
 *
 * @param string Phone Number
 * @param string Text
 * @param bool   Masking       Tidak menggunakan SMS Masking 
 *                             secara default
 *
 * @return object|bool
 * --------------------------------------------------------------
 */
 // send tanpa masking
 $status = $rajasms->send('082123456789','Testing Raja SMS API');

 // send dengan masking
 $status = $rajasms->send('082123456789','Testing Raja SMS API', TRUE);

// send sms ke banyak nomor sekaligus (max 1000)
$status = $rajasms->send(['081234567890', '08211234567890'], 'Testing Raja SMS API');

/*
 * --------------------------------------------------------------
 * Menerima Reporting pada Controller Callback
 *
 * @return object|bool
 * --------------------------------------------------------------
 */
 $rajasms->getReports();

/*
 * --------------------------------------------------------------
 * Melakukan checking credit balance
 *
 * @return mixed
 * --------------------------------------------------------------
 */
$credit = $rajasms->getCreditBalance();