PHP code example of by-zer0 / sms-assistant-php

1. Go to this page and download the library: Download by-zer0/sms-assistant-php 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/ */

    

by-zer0 / sms-assistant-php example snippets




use ByZer0\SmsAssistantBy\Client;
use ByZer0\SmsAssistantBy\Http\GuzzleClient;

$client = (new Client(new GuzzleClient()))
    ->setUsername('<username>') // Set username to pass API authorization.
    ->setSender('<sender-name>') // Set default sender name.
    ->setPassword('<password>'); // Set account password to pass API authorization.
//    ->setToken('<token>'); // Optional, set access token instead of password.

$default = [
    'sender' => '<default-sender>',
    'text' => 'This is default message text',
];

$messages = [
    [
        'phone' => '+375294011111',
        'sender' => 'notdefault',
        'text' => 'Message for first recipient',
    ],
    [
        'phone' => '+375294022222', // default sender name and text will be used
    ],
];

$client->sendMessages($messages, $default);

$client->sendMessage('+375294011111', 'Example message text');