A year ago, due to work needs, to Israel's colleagues to explain the text message platform of the SMS send format, I did not understand Python I have to write a sample, relatively coarse, can use, but not graceful, hope to learn Python can be changed like my colleague wrote so elegant
#!/usr/bin/python#coding:utf8import sys,httplib,urllib,urllib2import xml.etree.ElementTree as etsms=u ' test SMS Content ' signature section ' ' #input message here with ' Gbk_string=sms.encode ("GBK") #encode to Gbkparams = Urllib.urlencode ({' Operid ': ' Platform account ', ' Operpass ': ' Platform password ', ' sendtime ': ' Send Time ', ' validtime ': ', ' appendid ': ' Add code ', ' Desmobile ': ' Receive SMS mobile phone number ', ' Content ': gbk_ String, ' ContentType ': ' 8 '}) url= '/HTTP Platform interface address/qxtsms/qxtfirewall ' send = urllib2. Request (url,params) response = Urllib2.urlopen (send) Res_page = Response.read () xml=res_page.decode (' GBK ') xml= Xml.replace (' GBK ', ' utf-8 ') root = et.fromstring (XML) codes=root.getiterator (' Code ') status=codes[0].textif status = = ' "Print" Message sent successfully! "Else: print" message failed to send! "
A case of a Python script for sending SMS messages from the Enterprise ICT message platform