A Quick Python App to Send SMS via SMSified’s REST API

Smsified 1Today Voxeo[1] launched SMSified a new service that lets you use a really simple RESTful API to send text messages within the US for only 1 cent per message. I and other colleagues have been writing about SMSified on the SMSified blog and after writing a tutorial about using SMSified with curl, I figured I’d play around with python a bit and code up an example of sending a SMS via python.

So here it is… stored up in my Github account, but also here:

#!/usr/bin/env python

# Really simple python app for playing with sending SMS messages
# via SMSified - http://www.smsified.com/
# Created by Dan York - May 2011

import json
import urllib

senderid = "dandemo"   #SMSified account
password = "notmyrealpassword" #SMSified password
sendernum = "5853260800"       #SMSified phone number

apiurl = "https://"+senderid+":"+password+"@api.smsified.com/v1/
smsmessaging/outbound/"+sendernum+"/requests"

address = "14079678424"        # Phone num to which you want to send
message = "Hello there"        # Whatever msg you want to send

data = urllib.urlencode((('address',address),('message',message)))

f = urllib.urlopen(apiurl,data)

print json.loads(f.read())['resourceReference']['resourceURL']

As you can see in the code, there are really only three lines of importance: the one building “apiurl”; the one urlencoding the data; and the one opening the URL. The rest are really just for the convenience of using variables.

The final line simply prints out the info included in the result JSON. I was going to (and still may) make that print out prettier or say something more… and if you are reading this sometime in the future, the version on Github may have already morphed and evolved into something different. The point is that now that you get JSON back, you can parse it and start to take action on it.

Anyway, this was just a quick sample app to experiment with SMSified. If you have checked out the new service, it’s free to set up a developer account and currently is free entirely during the beta period.

[1] In full disclosure, Voxeo is my employer.

3 thoughts on “A Quick Python App to Send SMS via SMSified’s REST API

  1. TQ

    This is a great service. Skype current charges 11 cents for sending a message within US. Obviously SMSified is much more competitive.

    Is SMSified unicode friendly? Suppose the receiver’s phone can read languages other than latin-based ones, will sending a Arabic/Chinese/Japanese message result in garbled code?

    Thanks

    Reply
  2. Hugo

    Hi there, I just signed up in smsified and try your code with my phone number as address. I just get an “White List is enforced, and address %1 is not in White List”. Not sure how to fix this…

    Reply
    1. Dan York Post author

      Hugo,

      Hmmm… I’m not sure what to tell you on this. I know the SMSified team is always working on the system while it is in beta and it sounds like they have added or changed the security settings. Unfortunately as I no longer work at Voxeo (as of 2 months ago), I am not connected to any changes they have made. Your best bet may be to post something to their support forums:

      http://www.smsified.com/support

      Or ping them on Twitter as @smsified.

      Thanks for alerting me to the issue. If I get more info I’ll update the post.
      Dan

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.