const axios = require("axios");
const https = require("https");
const btoa = require("btoa");
const content_type = "application/json";
const api-key = "<api-key>";
const api-scret = "<api-scret>";
function pin_request() {
axios
.post(
"https://smsbox.devotek.africa/api/otp/v1/request",
{
app_id: 1,
receiver: "255701000000",
},
{
headers: {
"Content-Type": content_type,
Authorization: "Basic " + btoa(api-key + ":" + api-scret),
},
httpsAgent: new https.Agent({
rejectUnauthorized: false,
}),
}
)
.then((response) => console.log("success", response.data))
.catch((error) => console.error(error));
}
pin_request();
<?php
$api-key='<api-key>';
$api-scret = '<api-scret>';
// The data to send to the API
$postData = array(
'app_id' => '1',
'receiver' => '255701000000',
);
$Url ='https://smsbox.devotek.africa/api/otp/v1/request';
// Setup cURL
$ch = curl_init($Url);
error_reporting(E_ALL);
ini_set('display_errors', 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Authorization:Basic ' . base64_encode("$api-key:$api-scret"),
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($postData)
));
// Send the request
$response = curl_exec($ch);
// Check for errors
if($response === FALSE){
echo $response;
die(curl_error($ch));
}
var_dump($response);
?>
https://github.com/SMSBox/beem-otp-api-sample/tree/master/requestPin