The SMS Broadcast API allows you to integrate SMS messaging into your systems. Our API is a simple, yet powerful way to connect to our SMS gateway. There is no extra cost to use this service.
SMS Broadcast have two separate SMS gateways for adding SMS capability to software: a full feature HTTP API and an easy to use email API.
The HTTP API lets you send and receive messages, check credit balances, and receive updates to the the status of sent messages. It is ideal for sending bulk SMS messages and single messages.
You need the facility to make a HTTP or HTTPS connection to our URL. Our documentation contains all the required information and examples.
It doesn't matter which programming language you use, as long as it can make a HTTP connection. We have example code for PHP and .NET, and the documentation provides language agnostic examples if you want to implement into another language like Ruby or Java.
HTTP API Documentation PHP SDKMany software packages with SMS capabilities can use the email-to-sms gateway to send messages.
Before working with the email API you need to setup an account and register your sending email address in your account settings.
Then it is as simple as emailing <mobilenumber>@send.smsbroadcast.co.uk. The first 160 characters of your message will then be sent in the SMS message
Our technical support staff can provide additional assistance implementing the email-to-sms service and configuring your software with the email API.
<?php
function sendSMS($content) {
$ch = curl_init('https://api.smsbroadcast.co.uk/api-adv.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
curl_close ($ch);
return $output;
}
$username = 'USERNAME';
$password = 'PASSWORD';
$destination = '0400000000'; //Multiple numbers can be entered, separated by a comma
$source = 'MyCompany';
$text = 'This is our test message.';
$ref = 'abc123';
$content = 'username='.rawurlencode($username).
'&password='.rawurlencode($password).
'&to='.rawurlencode($destination).
'&from='.rawurlencode($source).
'&message='.rawurlencode($text).
'&ref='.rawurlencode($ref);
$smsbroadcast_response = sendSMS($content);
$response_lines = explode("\n", $smsbroadcast_response);
foreach( $response_lines as $data_line){
$message_data = "";
$message_data = explode(':',$data_line);
if($message_data[0] == "OK"){
echo "The message to ".$message_data[1]." was successful, with reference ".$message_data[2]."\n";
}elseif( $message_data[0] == "BAD" ){
echo "The message to ".$message_data[1]." was NOT successful. Reason: ".$message_data[2]."\n";
}elseif( $message_data[0] == "ERROR" ){
echo "There was an error with this request. Reason: ".$message_data[1]."\n";
}
}
?>
<?php
function sendSMS($content) {
$ch = curl_init('https://api.smsbroadcast.co.uk/api-adv.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
curl_close ($ch);
return $output;
}
$username = 'USERNAME';
$password = 'PASSWORD';
$action = 'balance';
$content = 'username='.rawurlencode($username).
'&password='.rawurlencode($password).
'&action='.rawurlencode($action);
$smsbroadcast_response = sendSMS($content);
$smsbroadcast_response = explode(':', $smsbroadcast_response);
if($smsbroadcast_response[0] == "OK"){
echo "SMS Broadcast balance is ".$smsbroadcast_response[1];
}elseif( $smsbroadcast_response[0] == "ERROR" ){
echo "There was an error with this request. Reason: ".$smsbroadcast_response[1]."\n";
}
?>
<?php
$to = $_GET["to"]; //The receiving mobile number
$from = $_GET["from"]; //The sending mobile number
$message = urldecode($_GET["message"]); //SMS content
// You may wish to log this information in a database
// Lets send an email with the message data
$email_message = "Inbound SMS sent to $to.\nSent From: $from\nMessage: $message";
mail("email@example.com", "Inbound SMS", $message, "From: email@example.com");
?>
<?php
$mobile = $_GET["to"]; //The receiving mobile number
$ref = $_GET["ref"]; // Your reference number, if provided when sending
$smsref = $_GET["smsref"]; // SMS Broadcast reference number
$status = $_GET["status"]; // Message status
// You may wish to log this information in a database
// Lets send an email with the updated data
$message = "Status update for SMS sent to $mobile.\nOur reference: $ref\nSMS Broadcast Reference: $smsref\nThe message status is now $status.";
mail("email@example.com", "SMS Status Update", $message, "From: email@example.com");
?>
using System.Net;
using System.IO;
WebClient client = new WebClient ();
client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
client.QueryString.Add("username", "xxxx");
client.QueryString.Add("password", "xxxx");
client.QueryString.Add("to", "xxxx");
client.QueryString.Add("from", "xxxx");
client.QueryString.Add("message", "Hello World!");
client.QueryString.Add("ref", "123");
client.QueryString.Add("maxsplit", "1");
string baseurl ="http://api.smsbroadcast.co.uk/api-adv.php";
Stream data = client.OpenRead(baseurl);
StreamReader reader = new StreamReader (data);
string s = reader.ReadToEnd ();
data.Close ();
reader.Close ();
return (s);
proudly works on all UK mobile networks