menu

Пример работы с SMS шлюзом на языке Python



Отправка смс:

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

Получения статуса отправленной смс*:

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

* Информация о статусе смс будет доступна спустя несколько минут после отправки


Получение цены отправки:

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
  

Получение баланса

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
  
Другие примеры:

Пример работы с SMS шлюзом на языке Java


Пример работы с SMS шлюзом на языке C#


Пример работы с SMS шлюзом на языке Perl


Пример подключения к шлюзу ePochta SMS 3.0 на PHP