API Documentation
API Documentation
{
"username": "[email protected]",
"password": "abc@123"
}
{
"accessToken":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzdXBlckBteWxpbmV4LmNvbSIsInR5cGUiO
iJhY2Nlc3NUb2tlbiIsImV4cCI6MTYyOTIyMzM0NiwiaWF0IjoxNjI5MjIyNzQ2fQ.QefL26z2LKOeVX9awXj
QajibL9MhzE4XjXqwaQ-ypWSXYbsSptn6wHIHcROtbh5P34MTORpZh98yykBQ298Fkw",
"refreshToken":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzdXBlckBteWxpbmV4LmNvbSIsInR5cGUi
OiJyZWZyZXNoVG9rZW4iLCJleHAiOjE2MjkzMDkxNDYsImlhdCI6MTYyOTIyMjc0Nn0.VUtAnwdSjsMesxs90
lw39GvYOLK8QY_cyHiFmYzYGtiX9AtCk1SmvWgn2-lh-5EgWJit6gRssHbeQvH-rqF5RA"
}
You can use the access token to access the send SMS API and the refresh token to renew the
access token when expired.
OAuth 2.0 Token Renew
This endpoint is used to renew the access token required to access the send SMS API, using the
refresh token provided at the login. The refresh token is sent in the header (Authorization:
Bearer [refresh token]).
Request URL :: https://bsms.hutch.lk/api/login/api/token/accessToken
{
"accessToken": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzdXBlckBteWxpbmV4LmNvbSIsInR5cGUi
OiJhY2Nlc3NUb2tlbiIsImV4cCI6MTYyOTIyMzM0NiwiaWF0IjoxNjI5MjIyNzQ2fQ.QefL26z2LKOeVX9awX
jQajibL9MhzE4XjXqwaQ-ypWSXYbsSptn6wHIHcROtbh5P34MTORpZh98yykBQ298Fkw"
}
If you receive HTTP error code 401 (Unauthorized) for the token renew API request, you should
call the login API to retrieve a fresh set of access and refresh tokens.
OAuth 2.0 Send SMS
This endpoint is used to send SMS, using the access token. The access token is sent in the
header (Authorization: Bearer [access token]).
Request URL :: https://bsms.hutch.lk/api/login/api/sendsms
{
"campaignName": "Test campaign",
"mask": "Test",
"numbers": "94780000000",
"content": "Test message"
}
{
"serverRef": 32225
}
If you receive HTTP error code 401 (Unauthorized) for the send SMS API request, you should
call the token renew API to retrieve a fresh access token.
Delivery report Enabling
If the delivery report required need to enable the delivery Report Request field fill in the Body
of send SMS as true.
"mask": "Test",
"numbers": "94780000000",
"deliveryReportRequest": true,
function login(){
global $config_file;
$post_data = array("username"=>"[email protected]","password"=>"testtest");
$ch = curl_init('https://bsms.hutch.lk/api/login');
curl_setopt_array($ch, array(
'Content-Type: application/json',
'Accept: */*',
'X-API-VERSION: v1'
),
));
$response = curl_exec($ch);
die(curl_error($ch));
curl_close($ch);
//echo $responseData['published'];
$ch = curl_init('https://bsms.hutch.lk/api/sendsms');
curl_setopt_array($ch, array(
'Content-Type: application/json',
'Accept: */*',
'X-API-VERSION: v1',
),
));
$response = curl_exec($ch);
Sample VB6 Code
Option Explicit
Debug.Print sendSms("test", "Test", "947xxxxxxx", "This is a test message from the Bulk SMSC, using VB")
End Sub
Close
tokenFile = "E:\path\token.txt"
userName = "[email protected]"
password = "testpwd"
End Sub
Public Function sendSms(campaignName As String, mask As String, numbers As String, content As String) As String
init
ss = readTokenFile()
accessToken = ss(0)
refreshToken = ss(1)
Call login
ss = readTokenFile()
accessToken = ss(0)
refreshToken = ss(1)
Exit Function
End If
End If
End Function
Private Function callSmsApi(campaignName As String, mask As String, numbers As String, content As String) As String
URL = "https://bsms.hutch.lk/api/sendsms"
json = "{" _
& Chr(34) & "campaignName" & Chr(34) & ":" & Chr(34) & campaignName & Chr(34) & "," _
& Chr(34) & "mask" & Chr(34) & ":" & Chr(34) & mask & Chr(34) & "," _
& Chr(34) & "numbers" & Chr(34) & ":" & Chr(34) & numbers & Chr(34) & "," _
& Chr(34) & "content" & Chr(34) & ":" & Chr(34) & content & Chr(34) & _
"}"
Debug.Print json
With hCon
.Send json
callSmsApi = .ResponseText
End With
End Function
URL = "https://bsms.hutch.lk/api/login"
json = "{" _
& Chr(34) & "username" & Chr(34) & ":" & Chr(34) & userName & Chr(34) & "," _
& Chr(34) & "password" & Chr(34) & ":" & Chr(34) & password & Chr(34) & _
"}"
Debug.Print json
Set hCon = CreateObject("WinHttp.WinHttpRequest.5.1")
With hCon
.Send json
response = .ResponseText
End With
response = makePretty(response)
Debug.Print response
writeTokenFile response
End Sub
strFileContent = Input(LOF(1), 1)
Close #1
'Debug.Print strFileContent
a = Split(strFileContent, ",")
a(0) = strip(a(0))
a(1) = strip(a(1))
b = Split(a(0), ":")
ss(0) = b(1)
c = Split(a(1), ":")
ss(1) = c(1)
readTokenFile = ss
Exit Function
fileErr:
ss(0) = "error"
ss(1) = "error"
readTokenFile = ss
End Function
strip = x
End Function
makePretty = x
End Function
Close #2
End Function