PHP code example of prihod / smsclubmobi-client

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

    

prihod / smsclubmobi-client example snippets




use SMSClubMobi\Client;

client = new Client($apiKey);

use SMSClubMobi\Request\BalanceRequest;
use SMSClubMobi\Exception\RequestException;

try {
    $request = new BalanceRequest();
    $response = $client->execute($request);

    if ($response->isSuccess()) {
        echo "Response to array:\n";
        print_r($response->toArray());
        echo "Response get data:\n";
        print_r($response->getData());
        if ($response->hasErrors()) {
            echo "Response get errors for parts:\n";
            print_r($response->getErrors());
        }
    } else {
        echo "Response Error: {$response->getError()}";
    }
} catch (RequestException $e) {
    echo "Exception: {$e->getMessage()}\n";
    print_r($e->request->toArray());
}

use SMSClubMobi\Request\SMSRequest;

 $request = (new SMSRequest())
        ->setPhone('380971234567')
        ->setSender('SMSSender')
        ->setMessage('Message text to be sent via SMS');

$response = $client->execute($request);
...

use SMSClubMobi\Request\SMSRequest;

 $request = (new SMSRequest())
        ->setPhone('380971234567')
        ->setPhone('380971234568')
        ->setSender('SMSSender')
        ->setMessage('Message text to be sent via SMS');

$response = $client->execute($requests);
...

use SMSClubMobi\Request\StatusSMSRequest;

 $request = (new StatusSMSRequest())
        ->setSMSId(1234)
        ->setSMSId(1235);

$response = $client->execute($request);
...

use SMSClubMobi\Request\ViberRequest;

  $request = (new ViberRequest())
        ->setPhone('380971234567')
        ->setSender('ViberTest')
        ->setMessage('Message text to be sent via Viber')
        ->setLink('https://smsclub.mobi/')
        ->setImage('https://smsclub.mobi/img/og_logo.jpg')
        ->setButtonText('Test');

$response = $client->execute($request);
...

use SMSClubMobi\Request\ViberSMSRequest;

$request = (new ViberSMSRequest())
        ->setPhone('380971234567')
        ->setSender('ViberTest')
        ->setMessage('Message text to be sent via Viber')
        ->setSMSSender('SMSTest')
        ->setSMSMessage('Message text to be sent via SMS')
        ->setLink('https://smsclub.mobi/')
        ->setImage('https://smsclub.mobi/img/og_logo.jpg')
        ->setButtonText('Test');

$response = $client->execute($request);
...

use SMSClubMobi\Request\Viber2WayRequest;

$request = (new Viber2WayRequest())
        ->setPhone('380971234567')
        ->setSender('ViberTest')
        ->setMessage('Message text to be sent via Viber');

$response = $client->execute($request);
...

use SMSClubMobi\Request\StatusViberRequest;

    $request = (new StatusViberRequest())
        ->setMessageId(1234)
        ->setMessageId(1235)
        ->setMessageId(1236);

$response = $client->execute($request);
...