#!/usr/bin/python # using http://www.txtlocal.co.uk # note: you need to set up an account with txtlocal to use this script (you get 10 free messages to try it out) import urllib, urllib2 def main(msg, numbers, user, sender_name): """ numbers recieved as string, comma separated""" # https://control.txtlocal.co.uk/docs/ hash = 'your_hash_here ** (get from link in comment above) **' test_flag = 0 # 0 for live 1 for test values = {'test' : test_flag, 'uname' : user, 'hash' : hash, 'message' : msg, 'from' : sender_name, 'selectednums' : numbers } url = 'http://www.txtlocal.com/sendsmspost.php' postdata = urllib.urlencode(values) req = urllib2.Request(url, postdata) print 'Attempt to send SMS ...' try: response = urllib2.urlopen(req) response_url = response.geturl() if response_url==url: print 'SMS sent!' except urllib2.URLError, e: print 'Send failed!' print e.reason if __name__ == '__main__': main()