Nič sa nenašlo

Inštalácia do Nette

Composer

Najjednoduchší spôsob, ako nainštalovať bulkgate/php-sdk do projektu, je pomocou nástroja Composer cez príkazový riadok.

composer require bulkgate/php-sdk

Nette DI Extension

Na inštaláciu SDK môžete použiť aj DI kontajner.

extensions: sdk: BulkGate\Sdk\DI\Extension sdk: application_id: 451 application_token: NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj sender: tag: 'sdk' # Optional default_country: cz # Optional configurator: sms: # Optional sender_id: gText sender_id_value: 'Example' unicode: true viber: # Optional sender: Sender button: caption: 'Button Caption' url: 'https://www.bulkgate.com/' image: url: 'https://www.example.com/example.png' zoom: true expiration: 3600 # seconds use BulkGate\Sdk\Sender; use BulkGate\Sdk\Message\Sms; class Sdk { private Sender $sender; public function __construct(Sender $sender) { $this->sender = $sender; } public function sendMessage(string $phone_number, string $text): void { $this->sender->send(new Sms($phone_number, $text)); } }

V predvolenom nastavení stačí application_id a application_token; ostatné voľby majú predvolené hodnoty. Navyše je možné nastaviť:

Voľba Predvolená hodnota Význam
application_product nette Identifikácia produktu v požiadavkách
connection.api https://portal.bulkgate.com/api/1.0/integration Adresa API
connection.content_type application/json Typ obsahu požiadavky
configurator.sms.country — Trasy podľa krajín; s ňou sa namiesto SmsConfigurator použije SmsCountryConfigurator
sdk: configurator: sms: country: cz: gate: gGate2 sender: 'BulkGate'

Pri Viberi je sender povinný, rovnako ako button.url a image.url, ak príslušnú sekciu uvediete.

Okrem sendera registruje rozšírenie aj služby `BulkGate\Sdk\NumberChecker` a `BulkGate\Sdk\CreditChecker`, takže si ich môžete nechať odovzdať konštruktorom.

Manuálne vytvorenie

use BulkGate\Sdk\Connection\ConnectionStream; use BulkGate\Sdk\MessageSender; use BulkGate\Sdk\Message\Sms; $connection = new ConnectionStream( /*application_id: */ 451, /*application_token:*/ 'NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj' ); $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));
Bola táto stránka užitočná?