Sending SMS vis API (1 Viewer)

wackywoo105

Registered User.
Local time
Yesterday, 22:12
Joined
Mar 14, 2014
Messages
203
I have a VoIP account and want to send SMS via the API. The details about it are here: https://support.aa.net.uk/SMS_API

They give an example for linux

Code:
curl --silent --form-string username=01234567890 --form-string password=123456 --form-string da=01234567890 --form-string ud="Hello world" https://sms.aa.net.uk/sms.cgi

Can anyone help with how to do this with Access VBA?
 

isladogs

MVP / VIP
Local time
Today, 06:12
Joined
Jan 14, 2017
Messages
18,235
I used Twilio for this for several years but haven't need to use the feature recently. However, their help documentation is excellent
 

cheekybuddha

AWF VIP
Local time
Today, 06:12
Joined
Jul 21, 2014
Messages
2,280
Actually, doesn't Windows have curl built-in now?

Daniel Pineault uses it to send an email on his blog here - can you adapt from that?

(Actually - he had difficulty getting the response back, which I guess is kinda necessary :( )
 

wackywoo105

Registered User.
Local time
Yesterday, 22:12
Joined
Mar 14, 2014
Messages
203
thanks. I tried the below but it errored on .Send

Code:
  Dim webServiceURL As String
  Dim actionType As String
  Dim targetWord As String
  Dim actionType2 As String
  Dim targetWord2 As String
  Dim actionType3 As String
  Dim targetWord3 As String
  Dim actionType4 As String
  Dim targetWord4 As String
 
  webServiceURL = "https://sms.aa.net.uk/sms.cgi"
  actionType = "username"
  targetWord = "myusername"
  actionType2 = "password"
  targetWord2 = "mypassword"
  actionType3 = "da"
  targetWord3 = "goingto"
  actionType4 = "ud"
  targetWord4 = "This is a test SMS."
    
' use late binding
  With CreateObject("Microsoft.XMLHTTP")
    .Open "GET", webServiceURL, False
    .SetRequestHeader actionType, targetWord
    .SetRequestHeader actionType2, targetWord2
    .SetRequestHeader actionType3, targetWord3
    .SetRequestHeader actionType4, targetWord4
    .Send
    If .Status = 200 Then
      Debug.Print .ResponseText
      MsgBox .GetAllResponseHeaders
    Else
      MsgBox .Status & ": " & .StatusText
    End If
  End With
 

cheekybuddha

AWF VIP
Local time
Today, 06:12
Joined
Jul 21, 2014
Messages
2,280
Try it like this:
Code:
  Const WEB_SERVICE_URL As String = "https://sms.aa.net.uk/sms.cgi"
  Const CONTENT_TYPE As String = "Content-Type"
  Const URL_ENCODED As String = "application/x-www-form-urlencoded"
  Dim data As String

  data = Array( _
    "username=myusername", _
    "password=mypassword", _
    "da=goingto", _
    Replace("ud=This is a test SMS.", " ", "+") _
  )
   
' use late binding
  With CreateObject("Microsoft.XMLHTTP")
    .Open "GET", WEB_SERVICE_URL, False
    .SetRequestHeader CONTENT_TYPE, URL_ENCODED
    .Send data.Join("&")
    If .Status = 200 Then
      Debug.Print .ResponseText
      MsgBox .GetAllResponseHeaders
    Else
      MsgBox .Status & ": " & .StatusText
    End If
  End With

You may not need to do the Replace() for the actual message part
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 06:12
Joined
Jul 9, 2003
Messages
16,282
I have used text magic:-

in the past because it's so simple! All you do is send an email to text magic and then it forwards the email as an SMS.

Extract from the text magic website:-

Send Email to SMS
Mobile marketing (for product promotion) is a very powerful tool for your business – and this is where sending SMS messages using email stands out.

You can set up a two-way communication without needing to write even one line of code: all you need is an email client and a TextMagic account. With this system, you can send ordinary emails, and your recipients will receive SMS messages (and vice versa, when they reply to you, you will receive their text through email).

Text magic API
I just had a look at text magic website and now they have an API. So it looks like both methods would be available to you.
 
Last edited:

wackywoo105

Registered User.
Local time
Yesterday, 22:12
Joined
Mar 14, 2014
Messages
203
Try it like this:
Code:
  Const WEB_SERVICE_URL As String = "https://sms.aa.net.uk/sms.cgi"
  Const CONTENT_TYPE As String = "Content-Type"
  Const URL_ENCODED As String = "application/x-www-form-urlencoded"
  Dim data As String

  data = Array( _
    "username=myusername", _
    "password=mypassword", _
    "da=goingto", _
    Replace("ud=This is a test SMS.", " ", "+") _
  )
  
' use late binding
  With CreateObject("Microsoft.XMLHTTP")
    .Open "GET", WEB_SERVICE_URL, False
    .SetRequestHeader CONTENT_TYPE, URL_ENCODED
    .Send data.Join("&")
    If .Status = 200 Then
      Debug.Print .ResponseText
      MsgBox .GetAllResponseHeaders
    Else
      MsgBox .Status & ": " & .StatusText
    End If
  End With

You may not need to do the Replace() for the actual message part
Thanks. I tried but I get a compile error saying "invalid qualifier" for the .Send data.Join("&") line with the word data highlighted.
 

cheekybuddha

AWF VIP
Local time
Today, 06:12
Joined
Jul 21, 2014
Messages
2,280
Sorry! Mixing languages!

Try it with:
Code:
' ...
    .Send Join(data, "&")
' ...
 

wackywoo105

Registered User.
Local time
Yesterday, 22:12
Joined
Mar 14, 2014
Messages
203
Sorry! Mixing languages!

Try it with:
Code:
' ...
    .Send Join(data, "&")
' ...
Many thanks. Only other change was "Dim data As Variant" and it worked perfectly. Received a debug.print of OK:1, a msgbox with some other info and of course the SMS.
 

wackywoo105

Registered User.
Local time
Yesterday, 22:12
Joined
Mar 14, 2014
Messages
203
And how did the sms come out on the recipient's end?
It was fine. Many thanks for your help.

I previously used a combination of tasker on an android phone to sync to a google drive folder to send SMS. My database places text files into the folder formatted a certain way, which are then synced every 10 minutes, read by tasker, and an SMS is sent. This is fine for non time sensitive SMS and the syncing is set to only operate during office hours. It has worked well for nearly 10 years. Any received SMS are also forwarded to me by tasker.

However, recently I've been working with integrating an online portal that produces signature requests which are only live for 3 minutes, so I required an instant SMS option if I want to send these. Thankfully having switched our phone lines to VOIP recently this is now catered for.

I may switch all SMS over to this new method, but will need to have a look into receiving SMS. The VOIP service allows me to specify an email address to receive SMS to, but when I tried this I just received a phone call that read the message out and no email.

Looking at https://support.aa.net.uk/SMS_API how would I go about receiving SMS using HTTP?
 
Last edited:

dtdukes86

Member
Local time
Today, 06:12
Joined
Aug 14, 2021
Messages
83
im not sure if you have alrleady tried but i uses twillio api for a access sms introgration and it works great in batch sms and individual sms.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 06:12
Joined
Sep 12, 2006
Messages
15,658
Have SMS messages changed? The issue with SMS used to be that it wasn't a free service, so you had to integrate with some paid for application somehow.
 

wackywoo105

Registered User.
Local time
Yesterday, 22:12
Joined
Mar 14, 2014
Messages
203
Do you have a webserver already set up?
I have a website. Could I configure this to receive messages and pass them on? Ideally I would like to receive the messages to my mobile. Are you familiar with tasker on android? I think it has a HTTP Server.
 

cheekybuddha

AWF VIP
Local time
Today, 06:12
Joined
Jul 21, 2014
Messages
2,280
Presumably, if you leave the settings without doing anything, then the SMS's sent to you will arrive at your phone normally?

I have a website. Could I configure this to receive messages and pass them on?
You can set up a script that will receive the SMS, process it, and I guess send it on (using your api) to your phone.

There are quite a few moving parts, so first thing would be to know more about your webserver setup.
 

wackywoo105

Registered User.
Local time
Yesterday, 22:12
Joined
Mar 14, 2014
Messages
203
Presumably, if you leave the settings without doing anything, then the SMS's sent to you will arrive at your phone normally?


You can set up a script that will receive the SMS, process it, and I guess send it on (using your api) to your phone.

There are quite a few moving parts, so first thing would be to know more about your webserver setup.
Thanks. I use groundwire app on my mobile (along with a normal phone and a grandstream HT812) and it has no options for SMS. I read somewhere it should have, so I will look into this first, as it will probably be simpler. Currently if I send an SMS to myself I receive a phone call (from BT for some reason) and the SMS is read out.
 
Last edited:

Users who are viewing this thread

Top Bottom