SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Other Forums
 Other Topics
 SMS from Python using HTTP request
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

thomasqueen
Starting Member

1 Posts

Posted - 01/25/2013 :  02:48:27  Show Profile  Reply with Quote
Hello. I have recently found a great way to send SMS messages from Python. It turns out, it is easy to send messages from Python using HTTP requestes and a software called Ozeki NG SMS Gateway. I downloaded and configured the software (they have great config info on their website) and then I use the sample source code:


###############################################

## Ozeki NG - SMS Gateway Python example ##

###############################################



import urllib



###############################################

### Ozeki NG informations ###

###############################################



host = "http://127.0.0.1"

user_name = "admin"

user_password = "abc123"

recipient = "+36304080332"

message_body = "Hello World from Python"



###############################################

### Putting together the final HTTP Request ###

###############################################



http_req = host

http_req += ":9501/api?action=sendmessage&username="

http_req += urllib.quote(user_name)

http_req += "&password="

http_req += urllib.quote(user_password)

http_req += "&recipient="

http_req += urllib.quote(recipient)

http_req += "&messagetype=SMS:TEXT&messagedata="

http_req += urllib.quote(message_body)



################################################

#### Sending the message ###

################################################

get = urllib.urlopen(http_req)

req = get.read()

get.close()



################################################

### Verifying the response ###

################################################



if req.find("Message accepted for delivery") > 1:

print "Message successfully sent"

else:

print "Message not sent! Please check your settings!"


More useful info on ozekisms.com/index.php?owpn=607

Have a nice day! Thomas
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000