PHP

Send Single SMS

try {

    $jwtToken = 'YOUR JWT TOKEN';
    $phoneNumber = '0912*******';
    $message = 'Hi, there';

    $client = new \GuzzleHttp\Client([
        'timeout' => 30,
    ]);

    $response = $client->request('POST', 'https://api.bitel.rest/api/v1/sms/single', [
        'headers' => [
            'Content-type' => 'application/json',
            'Authorization' => 'Bearer ' . $jwtToken,
        ],
        'body' => json_encode([
            'phoneNumber' => $phoneNumber,
            'message' => $message,
        ])
    ]);
    
    $responseJson = json_decode($response->getBody(), true);
    if ($responseJson['error'] != null) {
        echo 'error: ' . $responseJson['error'];
    } else {
        $requestId = $responseJson['result']['requestId'];
        echo 'requestId is: ' . $requestId;
    }
} catch (\Throwable $th) {
    echo 'exception: ' . $th->getMessage();
}

Send P2P SMS

<?php
try {

    $jwtToken = 'YOUR JWT TOKEN';
    $phoneNumbers = ['0912*******', '0936*******'];
    $messages = ['Hi, there', 'Hello, there'];

    $client = new \GuzzleHttp\Client([
        'timeout' => 30,
    ]);

    $response = $client->request('POST', 'https://api.bitel.rest/api/v1/sms/p2p', [
        'headers' => [
            'Content-type' => 'application/json',
            'Authorization' => 'Bearer ' . $jwtToken,
        ],
        'body' => json_encode([
            'phoneNumbers' => $phoneNumbers,
            'messages' => $messages,
        ])
    ]);
    
    $responseJson = json_decode($response->getBody(), true);
    if ($responseJson['error'] != null) {
        echo 'error: ' . $responseJson['error'];
    } else {
        $batchId = $responseJson['result'];
        echo 'batchId is: ' . $batchId;
    }
} catch (\Throwable $th) {
    echo 'exception: ' . $th->getMessage();
}

Send OTP Code

<?php
try {

    $jwtToken = 'YOUR JWT TOKEN';
    $phoneNumber = '0912*******';
    $text = '1234';

    $client = new \GuzzleHttp\Client([
        'timeout' => 30,
    ]);

    $response = $client->request('POST', 'https://api.bitel.rest/api/v1/voice/otp', [
        'headers' => [
            'Content-type' => 'application/json',
            'Authorization' => 'Bearer ' . $jwtToken,
        ],
        'body' => json_encode([
            'phoneNumber' => $phoneNumber,
            'text' => $text,
        ])
    ]);
    
    $responseJson = json_decode($response->getBody(), true);
    if ($responseJson['error'] != null) {
        echo 'error: ' . $responseJson['error'];
    } else {
        $requestId = $responseJson['result']
        echo 'requestId is: ' . $requestId;
    }
} catch (\Throwable $th) {
    echo 'exception: ' . $th->getMessage();
}

Make Single Call

<?php
try {

    $jwtToken = 'YOUR JWT TOKEN';
    $phoneNumber = '0912*******';
    $voiceId = 'VOICE ID';

    $client = new \GuzzleHttp\Client([
        'timeout' => 30,
    ]);

    $response = $client->request('POST', 'https://api.bitel.rest/api/v1/voice/otp', [
        'headers' => [
            'Content-type' => 'application/json',
            'Authorization' => 'Bearer ' . $jwtToken,
        ],
        'body' => json_encode([
            'phoneNumber' => $phoneNumber,
            'voiceId' => $voiceId,
        ])
    ]);
    
    $responseJson = json_decode($response->getBody(), true);
    if ($responseJson['error'] != null) {
        echo 'error: ' . $responseJson['error'];
    } else {
        $requestId = $responseJson['result'];
        echo 'requestId is: ' . $requestId;
    }
} catch (\Throwable $th) {
    echo 'exception: ' . $th->getMessage();
}

Last updated