PHP code example of bulkgate / php-sdk

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

    

bulkgate / php-sdk example snippets

 

use BulkGate\Sdk\Sender;
use BulkGate\Sdk\Message\Sms;

class Sdk
{
    private Sender $sender;

    public funnction __construct(Sender $sender)
    {
        $this->sender = $sender;
    }
    

    public function sendMessage(string $phone_number, string $text): void
    {    
        $this->sender->send(new Sms($phone_number, $text));
    }
}

 
use BulkGate\Sdk\Connection\ConnectionStream;
use BulkGate\Sdk\MessageSender;
use BulkGate\Sdk\Message\Sms;

$connection = new ConnectionStream(
    /*application_id: */ 0000, 
    /*application_token:*/ 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
);

$sender = new MessageSender($connection);

$sender->send(new Sms($phone_number, $text));

/* Optional */

$sender->setTag('sdk');

$sender->setDefaultCountry('cz');

$viber_configurator = new ViberConfigurator('Sender');
$viber_configurator->button('Button Caption', 'https://www.bulkgate.com/');
$viber_configurator->image('https://www.example.com/example.png', true);
$viber_configurator->expiration(3_600);

$sender->addSenderConfigurator($viber_configurator);

$sms_configurator = new SmsConfigurator('gText', 'Example', true);

$sender->addSenderConfigurator($sms_configurator);

$sender->send(new Sms($phone_number, $text));

composer