Send SMS Gateway API – VB6

This command can be used to send text messages to either individual numbers or entire contact groups.

Sample Request

                    
  1. Private Sub Command1_Click()
  2. Dim authKey, URL, mobiles, senderId, smsContentType, message, groupId, signature, routeId As String
  3. Dim V_signature, V_groupId, scheduleddate, V_scheduleddate As String
  4. Dim objXML As Object
  5. Dim getDataString As String
  6. authKey = "Sample Auth key" 'eg -- 16 digits alphanumeric
  7. URL = "Sample" 'eg-- www.abc.com
  8. mobiles = "Sample" '99999999xx,99999998xx
  9. smsContentType = "english" 'eg - english or unicode
  10. message = "Hello this is test"
  11. senderId = "Sample" 'eg -- Testin'
  12. routeId = “Sample" 'eg 1'
  13. scheduleddate = "" ‘optional if(scheduledate eg “26/08/2015 17:00”)
  14. signature ="" ‘optional if(signature available eg “1”)
  15. groupId ="" ‘optional if(groupId available eg “1”)
  16. If (Len(signature) > 0) Then
  17. V_signature = "&signature=" & signature
  18. End If
  19. If (Len(groupId) > 0) Then
  20. V_groupId = "&groupId=" & groupId
  21. End If
  22. If (Len(scheduleddate) > 0) Then
  23. V_scheduleddate = "&scheduleddate=" & scheduleddate
  24. End If
  25. URL = "Sample"
  26. 'use for API Reference
  27. Set objXML = CreateObject("Microsoft.XMLHTTP")
  28. 'creating data for url
  29. getDataString = URL + "AUTH_KEY=" + authKey + "&smsContent=" + message + "&mobileNos=" + mobiles + "&senderId=" + senderId + "&routeId=" + routeId +
  30. "&smsContentType=" + smsContentType + V_scheduleddate + V_groupId + V_signature
  31. objXML.Open "GET", getDataString, False
  32. objXML.Send
  33. If Len(objXML.ResponseText) > 0 Then
  34. MsgBox objXML.ResponseText
  35. End If
  36. End Sub
  37. Function URLEncode(ByVal Text As String) As String
  38. Dim i As Integer
  39. Dim acode As Integer
  40. Dim char As String
  41. URLEncode = Text
  42. For i = Len(URLEncode) To 1 Step -1
  43. acode = Asc(Mid$(URLEncode, i, 1))
  44. Select Case acode
  45. Case 48 To 57, 65 To 90, 97 To 122
  46. ' don't touch alphanumeric chars
  47. Case 32
  48. ' replace space with "+"
  49. Mid$(URLEncode, i, 1) = "+"
  50. Case Else
  51. ' replace punctuation chars with "%hex"
  52. URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _
  53. (URLEncode, i + 1)
  54. End Select
  55. Next
  56. End Function
                    
  1. Private Sub Command1_Click()
  2. Dim As Object
  3. Dim message As String
  4. Dim authKey As String
  5. Dim mobileNos As String
  6. Dim senderId As String
  7. Dim routeId As String
  8. Dim groupId As String
  9. Dim sURL, URL As String
  10. Dim smsContentType As String
  11. Dim signature As String
  12. Dim returnData As String
  13. 'Set these variables
  14. authKey = "Sample Auth key"'eg -- 16 digits alphanumeric
  15. URL = "Sample"'eg-- www.abc.com
  16. mobileNos = "Sample"'99999999xx,99999998xx
  17. smsContentType = "english"'eg - english or unicode
  18. message = "Hello this is test"
  19. senderId = "Sample" 'eg -- Testin'
  20. routeId = “Sample" 'eg 1'
  21. scheduleddate = "" ‘optional if(scheduledate eg “26/08/2015 17:00”)
  22. signature ="" ‘optional if(signature available eg “1”)
  23. groupId ="" ‘optional if(groupId available eg “1”)
  24. 'adding URL + AuthKey
  25. sURL = URL & "?AUTH_KEY=" & authKey
  26. Set objXML = CreateObject("Microsoft.XMLHTTP")
  27. objXML.Open "POST", sURL, False
  28. objXML.SetRequestHeader "Content-Type", "application/json"
  29. returnData = SendSMSPostData(message, senderId, routeId, mobileNos, smsContentType, signature, groupId, scheduleddate)
  30. ' Text1.Text = returnData
  31. objXML.Send returnData
  32. MsgBox returnData
  33. ' objXML.Send (returnData)
  34. '"AUTH_KEY=" + authKey + "smsContent=" + message + "&mobileNumbers=" + mobiles + "&senderId=" + sender + "&routeId=" + route + "&smsContentType=" + smsContent
  35. If Len(objXML.ResponseText) > 0 Then
  36. MsgBox objXML.ResponseText
  37. End If
  38. End Sub
  39. Function SendSMSPostData(smsContent As String, senderId As String, routeId As String,
  40. mobileNos As String, smsContentType As String, signature As String, groupId As String, scheduleddate As String) As String
  41. Dim data, V_groupId, V_mobileNos, V_senderId, V_smsContentType, V_signature, V_routeId, V_authKey, V_smsContent, V_scheduleddate As String
  42. 'V_authKey = "AUTH_KEY=" & authKey
  43. 'sURL = "Sample"
  44. V_smsContent = "{""smsContent""" & ":""" & smsContent & ""","
  45. V_routeId = """routeId""" & ":""" & routeId & ""","
  46. V_groupId = """groupId""" & ":""" & groupId & ""","
  47. V_mobileNos = """mobileNumbers""" & ":""" & mobileNos & ""","
  48. V_senderId = """senderId""" & ":""" & senderId & ""","
  49. V_smsContentType = """smsContentType""" & ":""" & smsContentType & """"
  50. data = V_smsContent & V_senderId & V_routeId & V_mobileNos & V_smsContentType & V_signature
  51. If (Len(signature) > 0) Then
  52. V_signature = ",""signature""" & ":""" & signature & """"
  53. data = data + V_signature
  54. ' MsgBox V_signature
  55. End If
  56. If (Len(groupId) > 0) Then
  57. V_groupId = ",""groupId""" & ":" & """ groupId & """""
  58. data = data + V_groupId
  59. 'MsgBox V_signature
  60. End If
  61. If (Len(scheduleddate) > 0) Then
  62. V_scheduleddate = ",""scheduleddate""" & ":" & """ scheduleddate & """""
  63. ' data = data + V_scheduleddatev
  64. End If
  65. data = data + "}"
  66. SendSMSPostData = data
  67. End Function
  68. Function URLEncode(ByVal Text >As String) As String
  69. Dim i As Integer
  70. Dim acode As Integer
  71. Dim char As String
  72. URLEncode = Text
  73. For i = Len(URLEncode) To 1 Step -1
  74. acode = Asc(Mid$(URLEncode, i, 1))
  75. Select Case acode
  76. Case 48 To 57, 65 To 90, 97 To 122
  77. ' don't touch alphanumeric chars
  78. Case 32
  79. ' replace space with "+"
  80. Mid$(URLEncode, i, 1) = "+"
  81. Case Else
  82. ' replace punctuation chars with "%hex"
  83. URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _
  84. (URLEncode, i + 1)
  85. End Select
  86. Next
  87. Function
                    
  1. Private Sub Command1_Click()
  2. Dim objXML As Object
  3. Dim message As String
  4. Dim authKey As String
  5. Dim mobileNos As String
  6. Dim senderId As String
  7. Dim routeId As String
  8. Dim groupId As String
  9. Dim sURL, URL As String
  10. Dim smsContentType As String
  11. Dim signature As String
  12. Dim returnData As String
  13. 'Set these variables
  14. authKey = "Sample Auth key" 'eg -- 16 digits alphanumeric
  15. URL = "Sample" 'eg-- www.abc.com
  16. mobileNos = "Sample" '99999999xx,99999998xx
  17. smsContentType = "english" 'eg - english or unicode
  18. message = "Hello this is test"
  19. senderId = "Sample" 'eg -- Testin'
  20. routeId = “Sample" 'eg 1'
  21. scheduleddate = "" ‘optional if(scheduledate eg “26/08/2015 17:00”)
  22. signature ="" ‘optional if(signature available eg “1”)
  23. groupId ="" ‘optional if(groupId available eg “1”)
  24. 'adding URL + AuthKey
  25. sURL = URL & "?AUTH_KEY=" & authKey
  26. Set objXML = CreateObject("Microsoft.XMLHTTP")
  27. objXML.Open "POST", sURL, False
  28. objXML.SetRequestHeader "Content-Type", "application/xml"
  29. returnData = SendSMSXMLData(authKey, message, senderId, routeId, mobileNos, smsContentType, signature, groupId, "")
  30. ' Text1.Text = returnData
  31. objXML.Send (returnData)
  32. '"AUTH_KEY=" + authKey + "smsContent=" + message + "&mobileNumbers=" + mobiles + "&senderId=" + sender + "&routeId=" + route + "&smsContentType=" + smsContent
  33. If Len(objXML.ResponseText) > 0 Then
  34. MsgBox objXML.ResponseText
  35. End If
  36. End Sub
  37. Function URLEncode(ByVal Text As String) As String
  38. Dim i As Integer
  39. Dim acode As Integer
  40. Dim char As String
  41. URLEncode = Text
  42. For i = Len(URLEncode) To 1 Step -1
  43. acode = Asc(Mid$(URLEncode, i, 1))
  44. Select Case acode
  45. Case 48 To 57, 65 To 90, 97 To 122
  46. ' don't touch alphanumeric chars
  47. Case 32
  48. ' replace space with "+"
  49. Mid$(URLEncode, i, 1) = "+"
  50. Case Else
  51. ' replace punctuation chars with "%hex"
  52. URLEncode = Left$(URLEncode, i - 1) & "%" & Hex$(acode) & Mid$ _
  53. (URLEncode, i + 1)
  54. End Select
  55. Next
  56. End Function
  57. Function SendSMSXMLData(authKey As String, smsContent As String, senderId As String, routeId As String, mobileNos As String,
  58. smsContentType As String, signature As String, groupId As String, scheduleddate As String) As String
  59. Dim data, V_groupId, V_mobileNos, V_senderId, V_smsContentType, V_signature, V_routeId, V_authKey, V_smsContent, V_scheduleddate As String
  60. 'V_authKey = "AUTH_KEY=" & authKey
  61. 'sURL = "http://167.114.186.70/rest/services/sendSMS/sendGroupSms"
  62. V_smsContent = "<smsContent>" & smsContent & "</smsContent>"
  63. V_routeId = "<routeId>" & routeId & "</routeId>"
  64. V_mobileNos = "<mobileNumbers>" & mobileNos & "</mobileNumbers>" '"""mobileNumbers""" & ":""" & mobileNos & ""","
  65. V_senderId = "<senderId>" & senderId & "</senderId>" '"""senderId""" & ":""" & senderId & ""","
  66. V_smsContentType = "<smsContentType>" & smsContentType & "</smsContentType>" '"""smsContentType""" & ":""" & smsContentType & """"
  67. If (Len(signature) > 0) Then
  68. V_signature = "<signature>" & signature & "</signature>" ' ",""signature""" & ":""" & signature & """"
  69. End If
  70. If (Len(groupId) > 0) Then
  71. V_groupId = ",""groupId""" & ":" & """ groupId & """""
  72. End If
  73. If (Len(scheduleddate) > 0) Then
  74. V_scheduleddate = ",""scheduleddate""" & ":" & """ scheduleddate & """""
  75. End If
  76. 'data = data + "</SMS>"
  77. data = "<Sms>" + "<AUTH_KEY>" + authKey + "</AUTH_KEY>" + V_smsContent & V_senderId & V_routeId & V_mobileNos & V_smsContentType & V_signature + "</Sms>"
  78. SendSMSXMLData = data
  79. 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.

Parameters

sender If you have a promotional account, do not send this parameter. If you have a transactional account, use this field to specify the sender name for your message. Sender name must be 6 alpha characters and should be pre-approved by Textlocal. In the absence of approved sender names, use the default 'TXTLCL'
message The message content. This parameter should be no longer than 766 characters. See Helpful Information for message length details. The message also must be URL Encoded to support symbols like &.
Login Parameters (Additional Information)
username The email address used to log into Textlocal.
hash Your secure hash can be found within Messenger in the main navigation under "Help->All Documentation". Alternatively you can use the password parameter instead and use your Textlocal password in plain text.
Optional Parameters
apiKey This can be used instead of the username/hash/password. You can create them in your Messenger Control Panel (click here) for each application, and limit the usage of them by host IP Address.
numbers Comma-delimited list of mobile numbers in international format (i.e. 918123456789).
group_id This parameter can be used in place of the numbers parameter in order to send to an entire contact group. This parameter should contain the ID of the relevant group, which can found either within Messenger (in the "Reports" - "Advanced Reports" - "List of Group ID's" section) or by running the get_groups command. Additionally group 5 contains "contacts" and group 6 contains "opt-outs".
schedule_time This parameter can be used to specify a schedule date/time for your message, which should be provided in Unix timestamp format. Times should be provided in GMT.
receipt_url Use this field to specify an alternative URL to which the delivery receipt(s) will be sent. See handling receipts documentation.
custom This value will be set against the message batch and will passed back in the delivery receipts. This allows you to match delivery receipts to their corresponding messages.
optouts Can be set to true in order to check against your own opt-outs list and Textlocal's global opt-outs database. Your message will not be sent to numbers within these lists. If not provided defaults to false.
unicode Set this value to true to specify that your message body will contain unicode characters. See Encoding/Decoding Unicode Documentation
test Set this field to true to enable test mode, no messages will be sent and your credit balance will be unaffected. If not provided defaults to false
Note 51: Error Code's for Missing Parameters:

Errors

Error Codes Description
3001 * for Success
3002 * Invalid URL
3003 * Invalid User/Password
3004 * Invalid Message Type
3005 * Invalid Message
3006 * Invalid Destination
3007 * Invalid Source
3008 * Invalid DLR Field
3009 * Authentication Failed
3010 * Internal Error
3011 * Insufficient Balance
3012 * Responce Time Out
3013 * Invalid Request Content Type
3014 * Missing Mobile Number
3015 * SMs Content for Approval
3016 * Missing Required Parameter
3017 * FAIL
3018 * Expired Account
3019 * Null Pointer Exception code
3020 * Empty User Name
3021 * Empty Password
3022 * User Name not Available
3023 * Session Expired
3024 * Already Exist
3025 * Empty Group Name
3026 * Empty Contact Name
3027 * Empty Mobile Number
3028 * Empty Group Id
3029 * Empty City Name
3030 * Empty Occupation
3041 * Empty E-Mail Id
3042 * Group not Exist
3043 * Empty Message
3044 * Empty Route Id
3045 * Empty Sender Id
3047 * Empty Draft Id
3048 * Empty First Name
3049 * Empty Last Name
3050 * Empty Balance
3051 * Empty Role Id
3052 * For User Name Length
3053 * Empty Expiry Date/td>
3054 * Invalid Date
3055 * Empty Client Id
3056 * Invalid Status
3057 * Empty Country Name
3058 * Empty State Name
3059 * Session Expired
3060 * Empty Date
3061 * Access Denied
3062 * Empty Old Password
3063 * Password not Maching
3064 * Empty SMS
3065 * Empty Amount
3066 * Empty Address
3067 * Empty RequestId
3068 * Empty Group and MobileNo
3069 * Empty Description
3070 * Fail to Change RoleId
3071 * Empty CallerId
3072 * Empty File URL and Draft
3073 * Empty Duration
3074 * Invalid Request
3075 * Invalid Aoudio file
3076 * Missing Upload File

Warnings

Warning Codes
3 Invalid number.
For Any Help Call Us Anywhere Anytime On   +91-94068-11127
Call Us +91-94068-11127