PHP code example of odenktools / wavecell-php

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

    

odenktools / wavecell-php example snippets


\Wavecell\Config::$timeZone = 'Asia/Jakarta';
\Wavecell\Config::$country = 'ID';
\Wavecell\Config::$resendInterval = 120;
\Wavecell\Config::$otpCodeValidity = 600;
\Wavecell\Config::$otpCodeLength = 6;
\Wavecell\Config::$smsExpireInMinutes = 60;
\Wavecell\Config::$subAccountId = 'YOUR_SUB_ACCOUNT_ID';
\Wavecell\Config::$secretKey = 'YOUR_SECRET_KEY';
\Wavecell\Config::$smsFrom = 'YOUR_APP_SETTING';

$sms = new \Wavecell\Sms();
$response = $sms->sendSingleSms('+6289671000082', 'HELLO WORLD, YOU CAN READ THIS SMS?', 'AUTO', false);
$body = (string)$response->getBody();
$code = (int)$response->getStatusCode();
if ($code === 400) {
    echo "BAD REQUEST";
} else if ($code === 401) {
    echo "Unauthorized ";
} else if ($code === 404) {
    echo "Not Found";
} else if ($code === 200) {
    $content = json_decode($body);
    echo $code . '<br/>';
    echo $content->status->code . '<br/>';
    echo $content->status->description. '<br/>';
    echo $content->umid. '<br/>';
    echo $content->encoding. '<br/>';
    echo $content->destination. '<br/>';
}

try {
    \Wavecell\Config::$timeZone = 'Asia/Jakarta';
    \Wavecell\Config::$country = 'ID';
    \Wavecell\Config::$resendInterval = 120;
    \Wavecell\Config::$otpCodeValidity = 600;
    \Wavecell\Config::$otpCodeLength = 6;
    \Wavecell\Config::$smsExpireInMinutes = 60;
    \Wavecell\Config::$subAccountId = 'YOUR_SUB_ACCOUNT_ID';
    \Wavecell\Config::$secretKey = 'YOUR_SECRET_KEY';
    \Wavecell\Config::$smsFrom = 'YOUR_APP_SETTING';

    $sms = new \Wavecell\Sms();
    $response = $sms->sendSingleSms('+6289671000082', 'HELLO WORLD, YOU CAN READ THIS SMS?', 'AUTO', true);
    $body = (string)$response->getBody();
    $code = (int)$response->getStatusCode();
    echo $code . '<br/>';
    echo $content->status->code . '<br/>';
    echo $content->status->description. '<br/>';
    echo $content->umid. '<br/>';
    echo $content->encoding. '<br/>';
    echo $content->destination. '<br/>';
} catch (\Wavecell\HttpException $exception) {
    echo $exception->getMessage();
}

try {
    \Wavecell\Config::$timeZone = 'Asia/Jakarta';
    \Wavecell\Config::$country = 'ID';
    \Wavecell\Config::$resendInterval = 120;
    \Wavecell\Config::$otpCodeValidity = 600;
    \Wavecell\Config::$otpCodeLength = 6;
    \Wavecell\Config::$smsExpireInMinutes = 60;
    \Wavecell\Config::$subAccountId = 'YOUR_SUB_ACCOUNT_ID';
    \Wavecell\Config::$secretKey = 'YOUR_SECRET_KEY';
    \Wavecell\Config::$smsFrom = 'YOUR_APP_SETTING';

    $sms = new \Wavecell\Sms();
    $numbers = array('+6289680000000', '+6289680000001');
    $response = $sms->sendMultipleSms('HELLO WORLD, YOU CAN READ THIS SMS?', $numbers);
    $body = (string)$response->getBody();
    $code = (int)$response->getStatusCode();
    echo $code . '<br/>';
    echo $content->status->code . '<br/>';
    echo $content->status->description. '<br/>';
    echo $content->umid. '<br/>';
    echo $content->encoding. '<br/>';
    echo $content->destination. '<br/>';
} catch (\Wavecell\HttpException $exception) {
    echo $exception->getMessage();
}

\Wavecell\Config::$timeZone = 'Asia/Jakarta';
\Wavecell\Config::$country = 'ID';
\Wavecell\Config::$resendInterval = 120;
\Wavecell\Config::$otpCodeValidity = 600;
\Wavecell\Config::$otpCodeLength = 6;
\Wavecell\Config::$smsExpireInMinutes = 60;
\Wavecell\Config::$subAccountId = 'YOUR_SUB_ACCOUNT_ID';
\Wavecell\Config::$secretKey = 'YOUR_SECRET_KEY';
\Wavecell\Config::$smsFrom = 'YOUR_APP_SETTING';

$sms = new \Wavecell\Sms();
$numbers = array('+6289680000000', '+6289680000001');
$response = $sms->sendMultipleSms('HELLO WORLD, YOU CAN READ THIS SMS?', $numbers, 'AUTO', false);
$body = (string)$response->getBody();
$code = (int)$response->getStatusCode();
if ($code === 400) {
    echo "BAD REQUEST";
} else if ($code === 401) {
    echo "Unauthorized ";
} else if ($code === 404) {
    echo "Not Found";
} else if ($code === 200) {
    $content = json_decode($body);
    echo $content->status->code . '<br/>';
    echo $content->status->description. '<br/>';
    echo $content->umid. '<br/>';
    echo $content->encoding. '<br/>';
    echo $content->destination. '<br/>';
}

try {
    \Wavecell\Config::$timeZone = 'Asia/Jakarta';
    \Wavecell\Config::$country = 'ID';
    \Wavecell\Config::$resendInterval = 120;
    \Wavecell\Config::$otpCodeValidity = 600;
    \Wavecell\Config::$otpCodeLength = 6;
    \Wavecell\Config::$smsExpireInMinutes = 60;
    \Wavecell\Config::$subAccountId = 'YOUR_SUB_ACCOUNT_ID';
    \Wavecell\Config::$secretKey = 'YOUR_SECRET_KEY';
    \Wavecell\Config::$smsFrom = 'YOUR_APP_SETTING';

    $sms = new \Wavecell\Sms();
    $response = $sms->sendOtpSms('+6289680000000', true);
    $body = (string)$response->getBody();
    $code = (int)$response->getStatusCode();
    echo $content->resourceUri . '<br/>';
    echo $content->uid . '<br/>';
    echo $content->status . '<br/>';
    echo $content->attempt. '<br/>';
    echo $content->expiresAt. '<br/>';
    echo $content->nextSmsAfter. '<br/>';
} catch (\Wavecell\HttpException $exception) {
    echo $exception->getMessage();
}

\Wavecell\Config::$timeZone = 'Asia/Jakarta';
\Wavecell\Config::$country = 'ID';
\Wavecell\Config::$resendInterval = 120;
\Wavecell\Config::$otpCodeValidity = 600;
\Wavecell\Config::$otpCodeLength = 6;
\Wavecell\Config::$smsExpireInMinutes = 60;
\Wavecell\Config::$subAccountId = 'YOUR_SUB_ACCOUNT_ID';
\Wavecell\Config::$secretKey = 'YOUR_SECRET_KEY';
\Wavecell\Config::$smsFrom = 'YOUR_APP_SETTING';

$sms = new \Wavecell\Sms();
$numbers = array('+6289680000000', '+6289680000001');
$response = $sms->sendOtpSms('+6289680000000', false);
$body = (string)$response->getBody();
$code = (int)$response->getStatusCode();
if ($code === 400) {
    echo "BAD REQUEST";
} else if ($code === 401) {
    echo "Unauthorized ";
} else if ($code === 404) {
    echo "Not Found";
} else if ($code === 200) {
    $content = json_decode($body);
    echo $content->resourceUri . '<br/>';
    echo $content->uid . '<br/>';
    echo $content->status . '<br/>';
    echo $content->attempt. '<br/>';
    echo $content->expiresAt. '<br/>';
    echo $content->nextSmsAfter. '<br/>';
}

try {
    \Wavecell\Config::$timeZone = 'Asia/Jakarta';
    \Wavecell\Config::$country = 'ID';
    \Wavecell\Config::$resendInterval = 120;
    \Wavecell\Config::$otpCodeValidity = 600;
    \Wavecell\Config::$otpCodeLength = 6;
    \Wavecell\Config::$smsExpireInMinutes = 60;
    \Wavecell\Config::$subAccountId = 'YOUR_SUB_ACCOUNT_ID';
    \Wavecell\Config::$secretKey = 'YOUR_SECRET_KEY';
    \Wavecell\Config::$smsFrom = 'YOUR_APP_SETTING';

    $sms = new \Wavecell\Sms();
    $response = $sms->verifyOtpSms('683cc08a-bf70-e911-8145-02d9baaa9e6f', '908273');
    $body = (string)$response->getBody();
    $code = (int)$response->getStatusCode();
    echo $content->resourceUri . '<br/>';
    echo $content->uid . '<br/>';
    echo $content->msisdn . '<br/>';
    echo $content->status . '<br/>';
    echo $content->attempt. '<br/>';
    echo $content->expiresAt. '<br/>';
} catch (\Wavecell\HttpException $exception) {
    echo $exception->getMessage();
}

\Wavecell\Config::$timeZone = 'Asia/Jakarta';
\Wavecell\Config::$country = 'ID';
\Wavecell\Config::$resendInterval = 120;
\Wavecell\Config::$otpCodeValidity = 600;
\Wavecell\Config::$otpCodeLength = 6;
\Wavecell\Config::$smsExpireInMinutes = 60;
\Wavecell\Config::$subAccountId = 'YOUR_SUB_ACCOUNT_ID';
\Wavecell\Config::$secretKey = 'YOUR_SECRET_KEY';
\Wavecell\Config::$smsFrom = 'YOUR_APP_SETTING';

$sms = new \Wavecell\Sms();
$response = $sms->verifyOtpSms('683cc08a-bf70-e911-8145-02d9baaa9e6f', '908273', false);
$body = (string)$response->getBody();
$code = (int)$response->getStatusCode();
if ($code === 400) {
    echo "BAD REQUEST";
} else if ($code === 401) {
    echo "Unauthorized ";
} else if ($code === 404) {
    echo "Not Found";
} else if ($code === 200) {
    $content = json_decode($body);
    echo $content->resourceUri . '<br/>';
    echo $content->uid . '<br/>';
    echo $content->msisdn . '<br/>';
    echo $content->status . '<br/>';
    echo $content->attempt. '<br/>';
    echo $content->expiresAt. '<br/>';
}
bash
composer