PHP code example of bundana / services

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

    

bundana / services example snippets


use Bundana\Services\Messaging\Mnotify;

// Example of sending a single SMS
$response = Mnotify::to('1234567890') // recipient phone number
    ->message('Hello, this is a test message!') // message content
    ->send(); // send the message

// The $response will contain the success status and details of the send operation
echo $response;

use Bundana\Services\Messaging\Mnotify;

// Example of checking balance
$response = Mnotify::SMSBalance(); // by default, checks using version 1

// If you need to check balance using version 2
$response_v2 = Mnotify::SMSBalance('v2');

// The $response will contain the SMS balance or an error message
echo $response;

use Bundana\Services\Messaging\Mnotify;

// Example of sending bulk SMS
$contactsAndMessages = [
    '1234567890' => 'Message to recipient 1',
    '0987654321' => 'Message to recipient 2',
    '5555555555' => 'Message to recipient 3',
];

$response = Mnotify::sendBulk($contactsAndMessages); // sending using version 1 by default

// To send using version 2, pass the 'v2' as a second argument
$response_v2 = Mnotify::sendBulk($contactsAndMessages, 'v2');

// The $response will contain the success status and details of the send operation
print_r($response);

use Bundana\Services\Messaging\Mnotify;

// Example of registering a sender ID
$senderId = 'MySenderID';
$purpose = 'Transactional Messages';

$response = Mnotify::registerSenderID($senderId, $purpose);

// The $response will contain the success status and details of the registration
echo $response;

  $customKeys = [
      'apiKey' => 'custom_api_key',
      'sender_id' => 'custom_sender_id',
  ];

  $response = Mnotify::to('1234567890')
      ->message('Hello, custom API keys!')
      ->newKeys($customKeys)
      ->send();
  

  $response = Mnotify::to('1234567890')
      ->message('This message will be sent later!')
      ->send(null, '2024-10-31 10:00:00');