Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 08c1b78

Browse files
committed
发送短信
1 parent 43fe65b commit 08c1b78

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

发送短信/main.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# @Time : 2020/4/14 15:42
2+
# @Author : Libuda
3+
# @FileName: main.py
4+
# @Software: PyCharm
5+
6+
import requests
7+
import json
8+
9+
10+
class SendSms:
11+
def __init__(self, api_key):
12+
self.api_key = api_key
13+
self.sing_send_url = 'https://sms.yunpian.com/v2/sms/single_send.json'
14+
15+
def send(self, code, mobile):
16+
params = {
17+
'apikey': self.api_key,
18+
'mobile': mobile,
19+
'text': '【李晋军test】您的验证码是{}。如非本人操作,请忽略本短信'.format(code)
20+
}
21+
response = requests.post(self.sing_send_url, data=params)
22+
resurt = json.loads(response.text)
23+
return resurt
24+
25+
26+
if __name__ == '__main__':
27+
sendsms = SendSms('65e7be01db4174b372508587a2e2c933')
28+
res = sendsms.send('1234', '15735656005')
29+
print(res)

0 commit comments

Comments
 (0)