Discuss SMS from Python using HTTP request in the Computer and Networking Forum area at ElectriciansForums.net

T

thomasqueen

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 their ozekisms site.

Have a nice day! Thomas
 
can't get mine to work.

220px-Lifeofbrian_harrison.jpg
 

Reply to SMS from Python using HTTP request in the Computer and Networking Forum area at ElectriciansForums.net

Similar Threads

D
Hello everyone, thanks for this nice forum! I'm looking for some raw logs of RS485/Modbus communications between an inverter and its smart meter...
Replies
0
Views
1K
Deleted member 147397
D
F
thought I'd copy this here Hopefully you will have seen the briefing document that we issued earlier this week and we will be following this up...
Replies
0
Views
1K
flamefix
F

OFFICIAL SPONSORS

Electrical Goods - Electrical Tools - Brand Names Electrician Courses Green Electrical Goods PCB Way Electrical Goods - Electrical Tools - Brand Names Pushfit Wire Connectors Electric Underfloor Heating Electrician Courses
These Official Forum Sponsors May Provide Discounts to Regular Forum Members - If you would like to sponsor us then CLICK HERE and post a thread with who you are, and we'll send you some stats etc

YOUR Unread Posts

This website was designed, optimised and is hosted by untold.media Operating under the name Untold Media since 2001.
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock