Created
April 6, 2011 16:46
-
-
Save toast38coza/906018 to your computer and use it in GitHub Desktop.
Code sample from bulksms.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//================================================ Python code sample ================================================// | |
import urllib | |
# If your firewall blocks access to port 5567, you can fall back to port 80: | |
# url = "http://bulksms.2way.co.za/eapi/submission/send_sms/2/2.0" | |
# (See FAQ for more details.) | |
url = "http://bulksms.2way.co.za:5567/eapi/submission/send_sms/2/2.0" | |
params = urllib.urlencode({'username' : 'myusername', 'password' : 'xxxxxxxx', 'message' : 'Testing Python', 'msisdn' : 271231231234}) | |
f = urllib.urlopen(url, params) | |
# Read from the object, storing the page's contents in 's'. | |
s = f.read() | |
# Print the contents | |
#print s | |
result = s.split('|') | |
statusCode = result[0] | |
statusString = result[1] | |
if statusCode != '0': | |
print "Error: " + statusCode + ": " + statusString | |
else: | |
print "Message sent: batch ID " + result[2] | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment