主函數,儲存為一個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):