Some of the information here may be outdated, please check the book instead
[edit]

from http://www.aspsms.com/examples/python/

def send_sms(recipient,text,userkey,password,host="xml1.aspsms.com",port=5061,action="/xmlsvr.asp"):
    import socket, cgi

    content="""<?xml version="1.0" encoding="ISO-8859-1"?>
<aspsms>
<Userkey>%s</Userkey>
<Password>%s</Password>
<Originator>"%s</Originator>
<Recipient>
<PhoneNumber>%s</PhoneNumber>
</Recipient>
<MessageData>%s</MessageData>
<Action>SendTextSMS</Action>
</aspsms>""" % (userkey,password,originator,recipient,cgi.escape(text))
    length=len(content)
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((host.port))
    s.send("POST %s HTTP/1.0\r\n",action)
    s.send("Content-Type: text/xml\r\n")
    s.send("Content-Length: "+str(length)+"\r\n\r\n")
    s.send(CONTENT)
    datarecv=s.recv(1024) 
    reply=str(datarecv)
    s.close()
    return reply

The aspsms service requires registration and it is not free. It is not secure either since transmission in not encrypted.

© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.