Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mobitel SMS skripta
import requests
class Mobitel_SMS:
def __init__(self, username, password):
self.username = username
self.password = password
def _send_request(self, action, body):
envelope = """<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>%s</soap:Body></soap:Envelope>"""
headers = {
'Content-Type': 'text/xml; charset=utf-8',
'User-Agent': 'XP Namiznik',
'SOAPAction': '"%s"' % (action),
'Except': '100-continue'
}
return requests.post('https://moj.mobitel.si/mobidesktop-v2/service',
data=envelope % (body),
headers=headers).text
def authenticateUser(self):
response = self._send_request(action='http://mobitel.si/MobiDesktop/AuthenticateUser', body="""<AuthenticateUser xmlns="http://mobitel.si/MobiDesktop">
<Username>%s</Username><Password>%s</Password></AuthenticateUser>""" % (self.username, self.password))
return response
def getPreference(self):
response = self._send_request(action='http://mobitel.si/MobiDesktop/GetPrefference', body="""<GetPrefference xmlns="http://mobitel.si/MobiDesktop">
<Username>%s</Username><Password>%s</Password><PreferenceIds><string>SaveSentSMS</string></PreferenceIds></GetPrefference>""" % (self.username, self.password))
return response
def monitor(self):
response = self._send_request(action='http://mobitel.si/MobiDesktop/Monitor', body="""<Monitor xmlns="http://mobitel.si/MobiDesktop">
<Username>%s</Username><Password>%s</Password></Monitor>""" % (self.username, self.password))
return response
def sendSMS(self, number, message):
response = self._send_request(action='http://mobitel.si/MobiDesktop/SendSMS', body="""<SendSMS xmlns="http://mobitel.si/MobiDesktop"><Username>%s</Username><Password>%s</Password>
<Recipients><string>%s</string></Recipients><Message>%s</Message></SendSMS>""" % (self.username, self.password, number, message))
return response
"""Uporaba:
m = Mobitel_SMS('051xxxxxx', 'geslo')
print m.sendSMS('041xxxxxx', 'sporocilo ...')"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment