Skip to content

Instantly share code, notes, and snippets.

@roman-yepishev
Created August 4, 2012 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roman-yepishev/3257761 to your computer and use it in GitHub Desktop.
Save roman-yepishev/3257761 to your computer and use it in GitHub Desktop.
Atompark SMS API v3.0 Example
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This code is in public domain
import json
import httplib2
import urllib
import hashlib
PUBLIC_KEY=''
PRIVATE_KEY=''
PHONE_NUMBER=''
ATOMPARK_GATEWAY_URL='http://atompark.com/api/sms/3.0'
message = u'This is a Test Message'.encode('utf-8')
args = {'sender': 'sms-info',
'text': message,
'phone': PHONE_NUMBER,
'datetime': '',
'sms_lifetime': 0,
'key': PUBLIC_KEY,
'version': '3.0',
'action': 'sendSMS',
'test': 1
}
sig_base_string = ''.join([ str(args[v]) for v in sorted(args.keys()) ])
sig_base_string += PRIVATE_KEY
sig = hashlib.md5(sig_base_string).hexdigest()
args['sum'] = sig
client = httplib2.Http()
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
body = urllib.urlencode(args)
resp, content = client.request(ATOMPARK_GATEWAY_URL + '/sendSMS',
method='POST',
headers=headers,
body=body)
print resp
print content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment