國都企信通簡訊平台傳送簡訊的python指令碼一例

來源:互聯網
上載者:User

標籤:

一年前,由於工作需要,給以色列的同事解釋一下國都簡訊平台的簡訊發送格式,本來不懂python的我硬著頭皮寫了一個sample,比較粗,能用,但不優美,希望以後學會python能改得像我同事寫的那麼優雅

 

#!/usr/bin/python#coding:utf8import sys,httplib,urllib,urllib2import xml.etree.ElementTree as ETsms=u‘測試簡訊內容【簽名部分】‘ #input message here with ‘‘gbk_string=sms.encode("gbk") #encode to GBKparams = urllib.urlencode({‘OperID‘:‘國都平台帳號‘,‘OperPass‘:‘平台密碼‘, ‘SendTime‘:‘發送時間‘,‘ValidTime‘:‘‘,‘AppendID‘:‘附加碼‘,‘DesMobile‘:‘接受簡訊的手機號碼‘, ‘Content‘:gbk_string,‘ContentType‘:‘8‘}) url=‘http://平台介面地址/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 == ‘03‘:          print "簡訊發送成功!"else:            print "簡訊發送失敗!"

  

國都企信通簡訊平台傳送簡訊的python指令碼一例

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.