PHP code example of neolikotsi / php-smsportal

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

    

neolikotsi / php-smsportal example snippets


use NeoLikotsi\SMSPortal\Message;
use NeoLikotsi\SMSPortal\RestClient;

$apiId = 'YOUR CLIENT API ID';
$apiSecret = 'YOUR CLIENT SECRET';
$baseRestUri = 'https://rest.smsportal.com/v1/';

$client = new RestClient($apiId, $apiSecret, $baseRestUri);
$message = new Message('Hello World');

// send to /bulkmessages endpoint
$responseArray1 = $client->message()->send([
                    'messages' => [
                        [
                            'destination' => '1234567890'
                            'content' => $message->getContent(),
                        ]
                    ]
                ]);

// send to /groupmessages endpoint
$responseArray2 = $client->message()->sendToGroup([
                    'message' => $message->getContent(),
                    'groups' => ['BloemfonteinStores', 'BotshabeloStores'],
                ]);

$client->balance();

$client->message()->inTestMode()->send([
    'messages' => [
        [
            'destination' => '1234567890'
            'content' => $message->getContent(),
        ]
    ]
]);
bash
composer