-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetion.py
44 lines (40 loc) · 1.19 KB
/
fetion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#coding:utf-8
#调用飞信
import urllib2
import urllib
class Fetion:
msisdn = ''
passwd = ''
baseurl = 'http://quanapi.sinaapp.com/fetion.php'
#设置登陆用户
def setuser(self,msisdn,passwd):
self.msisdn = msisdn
self.passwd = passwd
#发送短信
def sendsms(self,recmsisdn,content):
cod = 1
if self.msisdn == '' :
cod = 0
return 'msisdn is null'
if self.passwd == '' :
cod = 0
return 'passwd is null'
if recmsisdn == '' :
cod = 0
return 'recmsisdn is null'
if content == '':
cod = 0
return 'content is null'
if cod == 1 :
smsurl = self.baseurl + '?u=' + self.msisdn + '&p=' + self.passwd + '&to='+recmsisdn +'&m=' + content
print smsurl
res = urllib2.urlopen(smsurl).read()
print res
#反馈调用结果
return res.split(',')[0].split(':')[1]
if __name__=='__main__':
newfetion = Fetion()
#设置登陆飞信的用户
newfetion.setuser('18201614369','mypassword')
#发送短信
print newfetion.sendsms('18201614369','测试')