PHP
//Set Time Zone as this is very important to ensure your messages are delievered on time
date_default_timezone_set('Africa/Accra');
$clientId = 'YOUR-CLIENT-ID';
$applicationSecret = 'YOUR-CLIENT-SECRET';
$url = 'https://api.helliomessaging.com/v2/sms';
$currentTime = date('YmdH');
$hashedAuthKey = sha1($clientId.$applicationSecret.$currentTime);
$senderId = 'HellioSMS';
$mobile_number = '233242813656';
$message = 'Welcome to Hellio Messaging PHP API Code Snippiet';
$params = [
'clientId' => $clientId,
'authKey' => $hashedAuthKey,
'senderId' => $senderId,
'msisdn' => $mobile_number,
'message' => $message
];
$ch = curl_init($url);
$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))
);
$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());
}
static string sha1(string input) {
var hash = new SHA1Managed().ComputeHash(Encoding.UTF8.GetBytes(input));
return string.Concat(hash.Select(b => b.ToString("x2")));
}
public static string HellioMessaging_SendSMS() {
var currentDate = DateTime.Now.ToString("yyyyMMddHH");
string applicationSecret = "Your Hellio Messaging Application Secret Here";
string clientId = "Your Hellio Messaging Client ID Here";
string hashedAuthKey = sha1(clientId + applicationSecret + currentDate);
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/v2/sms", new NameValueCollection() {
{
"clientId",
clientId
}, {
"authKey",
hashedAuthKey
}, {
"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/v2/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-MESSAGING-USERNAME';
final password = 'YOU-HELLIO-MESSAGING-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/2/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/v2/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'
require 'digest/sha1'
currentTime = Time.new("%Y %m %d %H')
clientId : 'YOUR-CLIENT-ID',
applicationSecret : 'YOUR-CLIENT-SECRET',
hashedAuthKey = Digest::SHA1.hexdigest(clientId + applicationSecret + currentTime)
params =
{
clientId: clientId,
authKey: hashedAuthKey,
senderId: 'HellioSMS',
msisdn: '233265515154',
message: 'Ruby Sending SMS',
username: 'Your-Hellio-Messaging-Username',
password: 'Your-Hellio-Messaging-Password'
}
url = URI('https://api.helliomessaging.com/v2/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-Messaging-Username',
my $password = 'Your-Hellio-Messaging-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/v2/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
const sha1 = require("sha1");
const axios = require("axios");
const moment = require("moment");
//Format date to support hasing
const utcMoment = moment.utc();
const currentDateTime = utcMoment.format("YYYYMMDDHH")
const applicationSecret = "YOUR-HELLIO-APPLICATION-SECRET";
const client_Id = "YOUR-HELLIO-CLIENT-ID";
const sender_Id = "HellioSMS";
const hashedAuthKey = sha1(client_Id + applicationSecret + currentDateTime);
axios.post('https://helliomessaging.com/api/v2/sms', {
senderId: sender_Id,
msisdn: "233242813656", //if you wish to send to multiple numbers at the sametime, use the comma delimiter e.g. 233242813656, 233242365878
message: "Welcome a new world of limitless possibilities with Hellio",
authKey: hashedAuthKey,
clientId: client_Id,
})
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error.response)
});
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/v2/sms"
form := url.Values{}
form.Add("username", "Your-Hellio-Messaging-Username")
form.Add("password", "Your-Hellio-Messaging-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))
}