主函数,保存为一个test.py文件,放在PyFetion文件夹的下面,或自已设置目录
import os
import re
import sys
import 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 True
def main():
print "getting out the weather code..."
msg = "你好"
print "/n", msg
# SendSMS("发送信息")
SendSMS(msg)
print "Done."
if __name__ == "__main__":
sys.exit(main())
下载PyFetion :
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):