A couple of days ago I have posted an explanation of how to send SMS messages over My Go Account using c#. I have decided to do the same but this time using Ruby. I will not go in detail of how to since the explanation can be found here
Requirements:
GO Mobile phone line
My Go account for the phone line (Free for every GO Mobile phone)
As the title says this post describes how to send SMS messages from GO mobile website www.go.com.mt/mygo/ programmatically with C#. This is for educational purposes only and I’m not affiliated in any way to GO. Use the contents of this page at your own risk.
Requirements:
GO Mobile phone line
My Go account for the phone line (Free for every GO Mobile phone)
To send an SMS a user first has to login with his mobile number and password as shown in Fig:1
If the login is successful the user is given access to the form in Fig:2 that takes recipients and a maximum of 420 characters in an SMS. When finished typing the desired SMS click send SMS button.
How to achieve the above programmatically?
To send an SMS there are needed two POSTs, one for Login and the other for the actual SMS to be sent. So a method for sending a POST over HTTPS was created.
Post_data – is the actual data that post will carry
Referrer – is the previous url the post request originated.
cookieC –keeps the cookie the Web Server sends to the browser to maintain the Session state. This is so that to keep the program logged to your My Go account between login and sending a SMS message.
To make sure the Web Server sends the same HTML code that it sends to the Web Browser, the UserAgent is spoofed to the same as the Web Browser used in this case FireFox 5.
Note: the HTML code was cleared from irrelevant tags for clarity. The tags removed include table for formatting and client side validation on the form data.
From the HTML code at https://www.go.com.mt/mygo/ we investigate the login form.
Development becomes easier with the use of Temper Data which empowers the developer to pause and inspect requests and their content. With some manual SMSes testing the query string was figured out.
The code was tested in Visual Studio 2010 in a Console Application the Target Framework was changed to .NET Framework 4 as shown in Fig:3 so as to be able to include the reference to System.Web shown in fig:4.
Make sure the following name spaces are included
using System.Text;
using System.Net;
using System.IO;
Final note
If multiple SMS are to be sent, one could separate login from sending SMS but keep in mind that the session times out after being idle for some time.
What is not included:
Error Handling.
Message Templates.
An explanation of how to send to multiple recipients. This is left for the reader to try out. (probably just separate the numbers with coma)
How to access and retrieve My Go phone book and how to add entries to it programmatically.
Between login and sending an SMS from the website a real web browser sends some GET/POST requests for autocomplete mobile numbers in the phonebook stored in the account. These are skipped entirely.
Does not cater beyond the 8 free daily SMSes that require confirmation from the user to charge the account for the SMS.