1. Go to this page and download the library: Download waix/waix-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/ */
waix / waix-php example snippets
x = new Waix\Client(getenv('WAIX_API_KEY'));
// $eventId — UUID, уже сохранённый в записи заказа или очереди уведомлений.
$result = $waix->messages->send([
'connection_id' => getenv('WAIX_CONNECTION_ID'),
'to' => '+77071234567',
'type' => 'template',
'template' => [
'name' => 'order_ready',
'language' => ['code' => 'ru'],
'components' => [['type' => 'body', 'parameters' => [['type' => 'text', 'text' => '42']]]],
],
], $eventId);
$otp = new Waix\Client(getenv('WAIX_OTP_PROJECT_KEY'));
$sent = $otp->otp->send(['to' => '+77071234567', 'ttl' => 300], $eventId);
// Сохраните $sent['data']['id'] в серверной сессии пользователя.
$status = $otp->otp->status($sent['data']['id']);
// $suppliedCode — код, введённый пользователем в той же сессии.
$verified = $otp->otp->verify($sent['data']['id'], $suppliedCode);
$waix = new Waix\Client(getenv('WAIX_API_KEY'), timeoutMs: 30000);