Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added support for SmsGlobal gateway

See http://smsglobal.com for defails
  • Loading branch information...
commit 38ccf601c8f1a27eb70cb0f827e30e478b96ef25 1 parent ad3cae8
@mludvig authored
View
2  Sms/Engines/GenericHttp.py
@@ -30,7 +30,7 @@ def sendOne(self, message, recipient):
debug("GenericHttp: ret_code: %s" % u.code)
if u.code != 200:
raise SmsError("HTTP Return code = %d" % u.code)
- ret_data = u.read()
+ ret_data = u.read().strip()
debug("GenericHttp: ret_data: %s" % ret_data)
return ret_data
View
22 Sms/Engines/SmsGlobal.py
@@ -0,0 +1,22 @@
+## Michal Ludvig <mludvig@logix.net.nz>
+## http://www.logix.cz/michal/devel/sms-cli
+## License: GPL Version 2
+
+from Sms.Logger import *
+from Sms.Exceptions import SmsError
+import GenericHttp
+
+class SmsDriver(GenericHttp.SmsDriver):
+ url_pattern = "https://www.smsglobal.com/http-api.php?action=sendsms&user=%(username)s&password=%(password)s&from=%(sender)s&to=%(recipient)s&text=%(message)s"
+
+ def sendOne(self, message, recipient):
+ debug("SmsGlobal.sendOne(%s)" % recipient)
+ ret = GenericHttp.SmsDriver.sendOne(self, message, recipient)
+ arr = ret.split("\n")[0].split(" ", 1)
+ if arr[0].startswith("OK"):
+ id = arr[1].split(":")[-1]
+ info("SMS(SmsGlobal) sent to %s with ID: %s" % (recipient, id))
+ else:
+ warning("SMS(SmsGlobal) failed to %s: %s" % (recipient, ret))
+
+# vim: et:sw=4:sts=4:sta:ai:
View
9 sms-cli.conf.template
@@ -21,3 +21,12 @@ api_id = "XXXXX"
engine = "MessageMedia"
username = "XXXXX"
password = "XXXXX"
+
+[smsglobal]
+## SMS Global gateway - http://smsglobal.com
+engine = "SmsGlobal"
+username = "XXXXX"
+password = "XXXXX"
+# The 'sender' parameter may not always be
+# observed but must be set.
+sender = "XXXXX"
Please sign in to comment.
Something went wrong with that request. Please try again.