pyFreeSMS: A Python API

This is a Python API to send free messages via the many online free SMS providers. It currently works only with 160by2; I’ll add support for Way2SMS et all soon, though I’m hoping people interested in a specific provider will extend this API themselves.

How Will This Help Me?

This is primarily intended for developers looking to send messages from their Python applications. For instance, I’m currently developing an application that periodically checks my passport application status and messages it to me.

Getting It

1. Go here, click on the Downloads button at the top-right, and select the archive format that you’re comfortable with.

2. Extracting the archive should now show you the pyFreeSMS folder and a README file.

Using It

1. Copy the pyFreeSMS folder to the directory where your code resides.

2. Import the API:

from pyFreeSMS import py160by2

3. Send your message with the sendmessage(username, password, targetPhoneNumber, message) function, replacing your account authentication details* where necessary:

py160by2.sendMessage('usrname','pwd','123','msg')

Contributing

Considering the number of free SMS providers out there, I’m hoping there are a lot of you who might want to extend this API to your liking. To start off, you’ll first need to install Git:

sudo apt-get install git-core

Then you’ll need to get the code:

git clone \

https://emaadmanzoor@github.com/emaadmanzoor/pyFreeSMS.git

This will download the required source code to the current directory. To commit your extended code and added modules, it’d be best to read up the friendly documentation at github itself.

13 responses to “pyFreeSMS: A Python API

  1. Cool.
    I use firebug while working on any code that requires parsing a webpage but I don’t specify the header information. If I were use a mobile user-agent, is there any tool to inspect elements as can be done using Firebug?

  2. Hi,
    I was just wondering why has the User Agent been specified as iPhone 4.0
    Is it that the data retrieved depends on the user-agent? More specifically, had the user agent been, let’s say, Chrome or Firefox, would the data retrieved still be the same? Is it that using iPhone as an agent results in lesser data which is perhaps easier to work with?
    (I’m a complete beginner, so I might not have made any sense above)

    • You hit the nail on the head; the data retrieved is a lot easier to parse if you’ve specified any mobile user-agent. (PS: 160by2 had a major UI redesign, so the pyFreeSMS scraper currently stands broken)

  3. Hii, I am also getting the same error

    It says login successful but getting MID failed.

    anty idea?

    • 160by2 had a redesign recently, so I’m guessing the scraping broke. It’d be awesome if you could fork the code on Github, patch the scraping logic and send in a pull request! I’ll take a look at it myself ASAP.

  4. Shashank Gupta

    Hey Emaad, was searching for something similar. Didn’t expect that i’ll end up here. Will review your script soon and maybe will create the way2sms version. Gr8 Going…

  5. I just tested this, it works fine; could be an issue with your network connection, or some other configuration problem. It ran successfully on 32 bit Ubuntu Linux 10.04, using Python 2.6.5.

  6. I got the same message.
    used the same code (2 lines) as u explained here.

    can you update the module?

  7. Hii, I tried your code :)

    It says login successful but getting MID failed.

    What could be the problem. I have provided all the parameters correctly.

    • Hmm I don’t know how to reproduce this problem, it’s working fine on the computers I’ve tested. I think it’s a network problem, or something else specific to your computer or 160by2 account. Or 160by2 could have changed their login mechanism. Can you paste the code you used to send a message?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s