PHP
//Set Time Zone as this is very important to ensure your messages are delivered on time
date_default_timezone_set('Africa/Accra');
// Account details
$username = 'ENTER-YOUR-HELLIO-USERNAME-HERE';
$password = 'ENTER-YOUR-HELLIO-USERNAME-PASSWORD';
// Prepare data for POST request
$baseUrl = 'https://api.helliomessaging.com/v1/sms';
$senderId = 'HellioSMS'; //Change this to your sender ID e.g. HellioSMS
$mobile_number = '233xxxxxxxxx'; //Change this to the recipient you wish to send the message to
$message = 'Thanks for choosing Hellio Messaging'; //The message to be send here
$params = [
'username' => $username,
'password' => $password,
'senderId' => $senderId,
'msisdn' => $mobile_number,
'message' => $message
];
// Send the POST request with cURL
$ch = curl_init($baseUrl);
$payload = json_encode($params);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($payload)
));
// Process your response here
$result = curl_exec($ch);
echo var_export($result, true);
curl_close($ch);
ASP.NET (C#)
using System;
using System.Security.Cryptography;
using System.Net;
using System.Collections.Specialized;
using System.Text;
using System.Linq;
public class Program
{
public static void Main()
{
//THIS IS MORE LIKE A CONSOLE LOG SO YOU SHOULD SEE THE STATUS OF THE MESSAGE IN YOUR CONSOLE
Console.WriteLine(HellioMessaging_SendSMS());
}
public static string HellioMessaging_SendSMS() {
string username = "Your Hellio Username";
string password = "Your Hellio Password";
string senderId = "HellioSMS";
string msisdn = "233265515154";
string message = "Thanks for choosing Hellio Messaging. This Is A Message Sent From A C# Code.";
using (var wb = new WebClient()) {
byte[] response = wb.UploadValues("https://api.helliomessaging.com/v1/sms", new NameValueCollection(){
{"username", username},
{"password", password},
{"msisdn", msisdn},
{"message", message},
{"senderId", senderId}
});
string result = System.Text.Encoding.UTF8.GetString(response);
return result;
}
}
}
Java
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
public class Main{
public static void main(String[] args)
{
//Your username key
String username = "&username=" + "YOU-HELLIO-MESSAGING-USERNAME";
String password = "&password=" + "YOU-HELLIO-MESSAGING-PASSWORD";
String message = "&message=" + "This SMS Was Sent From A Java Code Sample";
String senderId = "&senderId=" + "HellioSMS";
String msisdn = "&msisdn=" + "233242813656";
//Prepare Url
URLConnection myURLConnection=null;
URL myURL=null;
BufferedReader reader=null;
//Base Endpoint
String baseUrl="https://api.helliomessaging.com/v1/sms";
//Prepare parameter string
StringBuilder sbPostData= new StringBuilder(baseUrl);
sbPostData.append("&username="+username);
sbPostData.append("&password="+password);
sbPostData.append("&senderId="+senderId);
sbPostData.append("&msisdn="+msisdn);
sbPostData.append("&message="+message);
//final string
baseUrl = sbPostData.toString();
try
{
//prepare connection
myURL = new URL(baseUrl);
myURLConnection = myURL.openConnection();
myURLConnection.connect();
reader= new BufferedReader(new InputStreamReader(myURLConnection.getInputStream()));
//reading response
String response;
while ((response = reader.readLine()) != null)
//print response
System.out.println(response);
//finally close connection
reader.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
Flutter
final username = 'YOU-HELLIO-USERNAME';
final password = 'YOU-HELLIO-PASSWORD';
final msisdn = '233265515154'; // Hellio Messaging supports sending messages to over 120 counties. Simply add the country code without the +
final senderId = 'HellioSMS'; //11 Characters max including space
final message = 'This a test message of Hellio Messaging's Flutter Code Snippet integration'; //message to send to recipient
Map headers = {"Content-type": "application/json"};
String params = '{
"username": username,
"password": password,
"msisdn": msisdn,
"senderId": senderId,
"message": message"
}';
final baseUrl = 'https://api.helliomessaging.com/v1/sms?'; // append parameters to the right position in the url
final response = await http.post(baseUrl, headers: headers, body: params); // This params accepts a match request. You can either use a Get or a Post method.
// Get response from your request
if(response.responseCode == 200){
// Meaning your message was sent successfully!
print('Response is: ${response.body}');
} else {
print('There was an issue sending message: ${response.body}');
}
Python
#!/usr/bin/env python
import urllib.request
import urllib.parse
def sendSMS(username, password, senderId, msisdn, message):
data = urllib.parse.urlencode({
'username': username,
'password': password,
'senderId':senderId,
'msisdn': msisdn,
'message' : message})
data = data.encode('utf-8')
request = urllib.request.Request("https://api.helliomessaging.com/v1/sms")
f = urllib.request.urlopen(request, data)
fr = f.read()
return(fr)
resp = sendSMS (
'Your-Hellio-Messaging-Username', 'Your-Hellio-Messaging-Password', 'HellioSMS', '233265515154,233540570577', 'This is a message from a Python Code sample')
print (resp)
Ruby
require 'uri'
require 'net/http'
params = {
senderId: 'HellioSMS',
msisdn: '233265515154',
message: 'Ruby Sending SMS',
username: 'Your-Hellio-Username',
password: 'Your-Hellio-Password' }
url = URI("https://api.helliomessaging.com/v1/sms")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url.request_uri,initheader = {'Content-Type' =>'application/json'})
request.body = params.to_json
response = http.request(request)
puts response.read_body
Perl
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
use HTTP::Request::Common;
my $username = 'Your-Hellio-Username',
my $password = 'Your-Hellio-Password'
my $senderId = "HellioSMS";
my $mobile_number = "233265515154";
my $message = "This is a message from Perl";
my $ua = LWP::UserAgent->new();
my $res = $ua->request
(
POST 'https://api.helliomessaging.com/v1/sms?',
Content_Type => 'application/x-www-form-urlencoded',
Content => [
'username' => $username,
'password' => $password,
'msisdn' => $mobile_number,
'message' => $message,
'senderId' => $senderId
]
);
if ($res->is_error) { die "HTTP Errorn"; }
print "Response:nn" . $res->content . "nn";
NodeJs
var request = require("request");
var options = { method: 'POST',
url: 'https://api.helliomessaging.com/v1/sms',
qs:
{
senderId: 'HellioSMS',
msisdn: '233265515154',
message: 'Nodejs Sending SMS',
username: 'Your-Hellio-Username',
password: 'Your-Hellio-Password' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
GoLang
package main
import (
"fmt"
"strings"
"net/url"
"net/http"
"io/ioutil"
)
func main() {
message := "Welcome to Hellio Messaging. Sending this message from a GOLANG code sample."
urlToPost := "https://api.helliomessaging.com/v1/sms"
form := url.Values{}
form.Add("username", "Your-Hellio-Username")
form.Add("password", "Your-Hellio-Password")
form.Add("msisdn", "233265515154")
form.Add("message", message)
form.Add("senderId", "HelioSMS")
fmt.Println(form.Encode())
req, _ := http.NewRequest("POST", urlToPost, strings.NewReader(form.Encode()))
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}