A case of a Python script for sending SMS messages from the Enterprise ICT message platform

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.