Code Samples

Ready-to-use code samples in PHP, Python, Node.js, Java, and more.

Code Samples

Ready-to-use code samples for integrating SBS TELECOM into your application. All samples use the HTTP REST API.

PHP

<?php
$apiKey = 'YOUR_API_KEY';
$data = [
    'to'   => '+447911123456',
    'from' => 'SBSTEL',
    'text' => 'Your OTP is 847291',
];
$ch = curl_init('https://api.sbstelecom.co.uk/v1/messages');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $apiKey,
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $response['id'];

Python

import requests

response = requests.post(
    "https://api.sbstelecom.co.uk/v1/messages",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={"to": "+447911123456", "from": "SBSTEL", "text": "Your OTP is 847291"}
)
print(response.json())

Node.js

const axios = require("axios");

const response = await axios.post(
  "https://api.sbstelecom.co.uk/v1/messages",
  { to: "+447911123456", from: "SBSTEL", text: "Your OTP is 847291" },
  { headers: { Authorization: "Bearer YOUR_API_KEY" } }
);
console.log(response.data.id);