menu
SMS gateway usage example for Python
Send sms:
login = "" password = "" phone_sms = "380633333131" msg_id = "123456" send_sms = '''<?xml version="1.0" encoding="UTF-8"?> <SMS> <operations> <operation>SEND</operation> </operations> <authentification> <username>%s</username> <password>%s</password> </authentification> <message> <sender>SMS</sender> <text>Test message [UTF-8]</text> </message> <numbers> <number messageID="%s">%s</number> </numbers> </SMS>''' % (login, password, phone_sms, msg_id) import urllib2, urllib senddata=[('XML',send_sms)] senddata=urllib.urlencode(senddata) path='http://api.atompark.com/members/sms/xml.php' req=urllib2.Request(path, senddata) req.add_header("Content-type", "application/x-www-form-urlencoded") result=urllib2.urlopen(req).read() print result
Get a status of sent sms*:
login = "" password = "" phone_sms = "380633333131" msg_id = "123456" get_sms_status = '''<?xml version="1.0" encoding="UTF-8"?> <SMS> <operations> <operation>GETPRICE</operation> </operations> <authentification> <username>%s</username> <password>%s</password> </authentification> <message> <sender>SMS</sender> <text>Test message [UTF-8]</text> </message> <numbers> <number messageID="%s">%s</number> </numbers> </SMS>''' % (login, password, phone_sms, msg_id) import urllib2, urllib senddata=[('XML',get_sms_status)] senddata=urllib.urlencode(senddata) path='http://api.atompark.com/members/sms/xml.php' req=urllib2.Request(path, senddata) req.add_header("Content-type", "application/x-www-form-urlencoded") result=urllib2.urlopen(req).read() print result
* The sms status information will be available in a few minutes
Get a price of sms:
login = "" password = "" phone_sms = "380633333131" msg_id = "123456" get_send_price = '''<?xml version="1.0" encoding="UTF-8"?> <SMS> <operations> <operation>GETPRICE</operation> </operations> <authentification> <username>%s</username> <password>%s</password> </authentification> <message> <sender>SMS</sender> <text>Test message [UTF-8]</text> </message> <numbers> <number messageID="%s">%s</number> </numbers> </SMS>''' % (login, password, phone_sms, msg_id) import urllib2, urllib senddata=[('XML',get_send_price)] senddata=urllib.urlencode(senddata) path='http://api.atompark.com/members/sms/xml.php' req=urllib2.Request(path, senddata) req.add_header("Content-type", "application/x-www-form-urlencoded") result=urllib2.urlopen(req).read() print result
Get a current balance
login = "" password = "" phone_sms = "380633333131" msg_id = "123456" get_balance = '''<?xml version="1.0" encoding="UTF-8"?> <SMS> <operations> <operation>BALANCE</operation> </operations> <authentification> <username>%s</username> <password>%s</password> </authentification> </SMS>''' % (login, password) import urllib2, urllib senddata=[('XML',get_balance)] senddata=urllib.urlencode(senddata) path='http://api.atompark.com/members/sms/xml.php' req=urllib2.Request(path, senddata) req.add_header("Content-type", "application/x-www-form-urlencoded") result=urllib2.urlopen(req).read() print result
Other examples:
SMS gateway usage example for PHP
SMS gateway usage example for C#
SMS gateway usage example for Perl