使用python指令碼,通過PyFetion給手機發訊息

來源:互聯網
上載者:User
主函數,儲存為一個test.py檔案,放在PyFetion檔案夾的下面,或自已設定目錄
import osimport reimport sysimport time  from PyFetion import *def SendSMS(sms):    myphone = '150********'  # 手機號    mypwd = 'ro**********'  # 登入密碼    destphone = ["150********"]  # 發送對象飛訊號    # 發送目的地改為飛訊號,之前用的手機號做目的地發送,別人的收不到簡訊    print "waiting for login fetion..."    fetion = PyFetion(myphone, mypwd, 'TCP')    fetion.login(FetionHidden)    for phone in destphone:        print "sending to", phone        fetion.send_sms(sms, phone, True)        print "OK"    fetion.logout()    return Truedef main():    print "getting out the weather code..."    msg = "你好"    print "/n", msg    #    SendSMS("發送資訊")    SendSMS(msg)    print "Done."if __name__ == "__main__":    sys.exit(main())      

下載PyFetion :

http://code.google.com/p/pytool/downloads/detail?name=PyFetion.rar&can=2&q=

PyFetion2010修正版

 

使用PyFetion時,有時會提醒你,輸入驗證碼。(驗證碼存在PyFeition產生的一個圖片當中。)

輸入驗證碼時會自動彈出驗證碼圖片(Windows下用內建圖片查看器),關閉圖片後再輸入驗證碼,否則不會出來輸入驗證碼的提示,輸入驗證碼時可以不用理會已輸入的字母被覆蓋。

 

PyFetion 公開的API:

PyFetion 初始化函數:

class PyFetion(SIPC):    __log = ''    __sipc_url = ''    _ssic = ''    _user_id = ''    _lock = RLock()    _sipc_proxy  = ''    _domain = ''    _http_tunnel = ''        mobile_no = ''    passwd = ''    queue = Queue()    sid = ''    login_type = ''    receving = False    presence = ''    debug = False    contactlist = {}    session = {}    verify = False    verify_info = []    def __init__(self,mobile_no,passwd,login_type="TCP",debug=False):        self.mobile_no = mobile_no        self.passwd = passwd        self.login_type = login_type        global log

********************************************************************************

def send_msg(self,msg,to=None,flag="CatMsg"):
def send_sms(self,msg,to=None,long=True):
def send_schedule_sms(self,msg,time,to=None):
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.