Skip to content

Instantly share code, notes, and snippets.

@Hellowlol
Created April 7, 2014 21:15
Show Gist options
  • Save Hellowlol/10058100 to your computer and use it in GitHub Desktop.
Save Hellowlol/10058100 to your computer and use it in GitHub Desktop.
telenor sms api python
#--coding: utf-8--
import urllib2
import urllib
from sys import argv
'''
Used for sending texts via telenor norway smapi
Send passord to 1999 to get your password
You will be billed by telenor for the usage even if sms is included in your subscription
'''
msg = argv[1]
recipients = argv[2]
def sendsms(msg, recipients=None):
sender = ''
password = ''
if recipients == None:
recipients = sender
try:
msg = urllib.quote_plus(msg)
sms_url = "https://telenormobil.no/smapi/3/sms?sender=%s&password=%s&recipients=%s&sId=1000000000&content=%s" % (sender, password, recipients, msg)
result = urllib2.urlopen(sms_url).read()
if 'RECIPIENT status="OK"' and 'RESPONSE processed="OK"' in result:
print 'The text was sendt successfully'
else:
print 'Failed: %s' % result
except Exception as e:
print 'Something failed: %s' % e
sendsms(msg, recipients)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment