Private Sub Command1_Click()
Dim authKey, URL, mobiles, senderId, smsContentType, message, groupId, signature, routeId As String
Dim V_signature, V_groupId, scheduleddate, V_scheduleddate As String
Dim objXML As Object
Dim getDataString As String
authKey = "Sample Auth key"
URL = "Sample"
mobiles = "Sample"
smsContentType = "english"
message = "Hello this is test"
senderId = "Sample"
routeId = “Sample" 'eg 1'
scheduleddate = "" ‘optional if(scheduledate eg “26/08/2015 17:00â€)
signature ="" ‘optional if(signature available eg “1â€)
groupId ="" ‘optional if(groupId available eg “1â€)
If (Len(signature) > 0) Then
V_signature = "&signature=" & signature
End If
If (Len(groupId) > 0) Then
V_groupId = "&groupId=" & groupId
End If
If (Len(scheduleddate) > 0) Then
V_scheduleddate = "&scheduleddate=" & scheduleddate
End If
URL = "Sample"
'use for API Reference
Set objXML = CreateObject("Microsoft.XMLHTTP")
'creating data for url
getDataString = URL + "AUTH_KEY=" + authKey + "&smsContent=" + message + "&mobileNos=" + mobiles + "&senderId=" + senderId + "&routeId=" + routeId + "&smsContentType=" + smsContentType + V_scheduleddate + V_groupId + V_signature
objXML.Open "GET", getDataString, False
objXML.Send
If Len(objXML.ResponseText) > 0 Then
MsgBox objXML.ResponseText
End If
End Sub
Function URLEncode(ByVal Text As String) As String
Dim i As Integer
Dim acode As Integer
Dim char As String
URLEncode = Text
For i = Len(URLEncode) To 1 Step -1
acode = Asc(Mid$(URLEncode, i, 1))
Select Case acode
Case 48 To 57, 65 To 90, 97 To 122
' don't touch alphanumeric chars
Case 32
' replace space with "+"
Mid$(URLEncode, i, 1) = "+"
Case Else
' replace punctuation chars with "%hex"
URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _
(URLEncode, i + 1)
End Select
Next
End Function
Private Sub Command1_Click()
Dim objXML As Object
Dim message As String
Dim authKey As String
Dim mobileNos As String
Dim senderId As String
Dim routeId As String
Dim groupId As String
Dim sURL, URL As String
Dim smsContentType As String
Dim signature As String
Dim returnData As String
authKey = "Sample Auth key"
URL = "Sample"
mobileNos = "Sample"
smsContentType = "english"
message = "Hello this is test"
senderId = "Sample"
routeId = “Sample" 'eg 1'
scheduleddate = "" ‘optional if(scheduledate eg “26/08/2015 17:00â€)
signature ="" ‘optional if(signature available eg “1â€)
groupId ="" ‘optional if(groupId available eg “1â€)
'adding URL + AuthKey
sURL = URL & "?AUTH_KEY=" & authKey
Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.Open "POST", sURL, False
objXML.SetRequestHeader "Content-Type", "application/json"
returnData = SendSMSPostData(message, senderId, routeId, mobileNos, smsContentType, signature, groupId, scheduleddate)
' Text1.Text = returnData
objXML.Send returnData
MsgBox returnData
' objXML.Send (returnData)
'"AUTH_KEY=" + authKey + "smsContent=" + message + "&mobileNumbers=" + mobiles + "&senderId=" + sender + "&routeId=" + route + "&smsContentType=" + smsContent
If Len(objXML.ResponseText) > 0 Then
MsgBox objXML.ResponseText
End If
End Sub
Function SendSMSPostData(smsContent As String, senderId As String, routeId As String, mobileNos As String, smsContentType As String, signature As String, groupId As String, scheduleddate As String) As String
Dim data, V_groupId, V_mobileNos, V_senderId, V_smsContentType, V_signature, V_routeId, V_authKey, V_smsContent, V_scheduleddate As String
'V_authKey = "AUTH_KEY=" & authKey
'sURL = "Sample"
V_smsContent = "{""smsContent""" & ":""" & smsContent & ""","
V_routeId = """routeId""" & ":""" & routeId & ""","
V_groupId = """groupId""" & ":""" & groupId & ""","
V_mobileNos = """mobileNumbers""" & ":""" & mobileNos & ""","
V_senderId = """senderId""" & ":""" & senderId & ""","
V_smsContentType = """smsContentType""" & ":""" & smsContentType & """"
data = V_smsContent & V_senderId & V_routeId & V_mobileNos & V_smsContentType & V_signature
If (Len(signature) > 0) Then
V_signature = ",""signature""" & ":""" & signature & """"
data = data + V_signature
' MsgBox V_signature
End If
If (Len(groupId) > 0) Then
V_groupId = ",""groupId""" & ":" & """ groupId & """""
data = data + V_groupId
'MsgBox V_signature
End If
If (Len(scheduleddate) > 0) Then
V_scheduleddate = ",""scheduleddate""" & ":" & """ scheduleddate & """""
' data = data + V_scheduleddate
End If
data = data + "}"
SendSMSPostData = data
End Function
Function URLEncode(ByVal Text As String) As String
Dim i As Integer
Dim acode As Integer
Dim char As String
URLEncode = Text
For i = Len(URLEncode) To 1 Step -1
acode = Asc(Mid$(URLEncode, i, 1))
Select Case acode
Case 48 To 57, 65 To 90, 97 To 122
' don't touch alphanumeric chars
Case 32
' replace space with "+"
Mid$(URLEncode, i, 1) = "+"
Case Else
' replace punctuation chars with "%hex"
URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _
(URLEncode, i + 1)
End Select
Next
End Function
Private Sub Command1_Click()
Dim objXML As Object
Dim message As String
Dim authKey As String
Dim mobileNos As String
Dim senderId As String
Dim routeId As String
Dim groupId As String
Dim sURL, URL As String
Dim smsContentType As String
Dim signature As String
Dim returnData As String
authKey = "Sample Auth key"
URL = "Sample"
mobileNos = "Sample"
smsContentType = "english"
message = "Hello this is test"
senderId = "Sample"
routeId = “Sample" 'eg 1'
scheduleddate = "" ‘optional if(scheduledate eg “26/08/2015 17:00â€)
signature ="" ‘optional if(signature available eg “1â€)
groupId ="" ‘optional if(groupId available eg “1â€)
'adding URL + AuthKey
sURL = URL & "?AUTH_KEY=" & authKey
Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.Open "POST", sURL, False
objXML.SetRequestHeader "Content-Type", "application/xml"
returnData = SendSMSXMLData(authKey, message, senderId, routeId, mobileNos, smsContentType, signature, groupId, "")
' Text1.Text = returnData
objXML.Send (returnData)
'"AUTH_KEY=" + authKey + "smsContent=" + message + "&mobileNumbers=" + mobiles + "&senderId=" + sender + "&routeId=" + route + "&smsContentType=" + smsContent
If Len(objXML.ResponseText) > 0 Then
MsgBox objXML.ResponseText
End If
End Sub
Function URLEncode(ByVal Text As String) As String
Dim i As Integer
Dim acode As Integer
Dim char As String
URLEncode = Text
For i = Len(URLEncode) To 1 Step -1
acode = Asc(Mid$(URLEncode, i, 1))
Select Case acode
Case 48 To 57, 65 To 90, 97 To 122
' don't touch alphanumeric chars
Case 32
' replace space with "+"
Mid$(URLEncode, i, 1) = "+"
Case Else
' replace punctuation chars with "%hex"
URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _
(URLEncode, i + 1)
End Select
Next
End Function
Function SendSMSXMLData(authKey As String, smsContent As String, senderId As String, routeId As String, mobileNos As String, smsContentType As String, signature As String, groupId As String, scheduleddate As String) As String
Dim data, V_groupId, V_mobileNos, V_senderId, V_smsContentType, V_signature, V_routeId, V_authKey, V_smsContent, V_scheduleddate As String
'V_authKey = "AUTH_KEY=" & authKey
'sURL = "https://msg.msgclub.net/rest/services/sendSMS/sendGroupSms"
V_smsContent = "<smsContent>" & smsContent & "</smsContent>"
V_routeId = "<routeId>" & routeId & "</routeId>"
V_mobileNos = "<mobileNumbers>" & mobileNos & "</mobileNumbers>" '"""mobileNumbers""" & ":""" & mobileNos & ""","
V_senderId = "<senderId>" & senderId & "</senderId>" '"""senderId""" & ":""" & senderId & ""","
V_smsContentType = "<smsContentType>" & smsContentType & "</smsContentType>" '"""smsContentType""" & ":""" & smsContentType & """"
If (Len(signature) > 0) Then
V_signature = "<signature>" & signature & "</signature> " ' ",""signature""" & ":""" & signature & """"
End If
If (Len(groupId) > 0) Then
V_groupId = ",""groupId""" & ":" & """ groupId & """""
End If
If (Len(scheduleddate) > 0) Then
V_scheduleddate = ",""scheduleddate""" & ":" & """ scheduleddate & """""
End If
'data = data + "</SMS>"
data = "<Sms>" + "<AUTH_KEY>" + authKey + "</AUTH_KEY>" + V_smsContent & V_senderId & V_routeId & V_mobileNos & V_smsContentType & V_signature + "</Sms>"
SendSMSXMLData = data
End Function
Caution: Some users opt to place their request inside a code loop, while testing we highly recommend setting the test parameter to true , as occasionally an infinite loop can occur and users can consume all their credits very quickly.