newmediamonitoring/dashboard/yunpian.py

23 lines
756 B
Python
Raw Normal View History

2020-10-13 13:33:48 +00:00
import requests
class YunPian(object):
def __init__(self, api_key):
self.api_key = api_key
self.single_send_url = 'https://sms.yunpian.com/v2/sms/single_send.json'
def send_sms(self, code, mobile):
params = {
'apikey': self.api_key,
'mobile': mobile,
'text': {'#dateStart#':'10月1日','#dateEnd#':'10日','#type#':'微信公众号','#name#':'武山县人民政府网'}
}
# text必须要跟云片后台的模板内容 保持一致,不然发送不出去!
r = requests.post(self.single_send_url, data=params)
print(r)
if __name__ == '__main__':
yun_pian = YunPian('304eb08353f7ebf00596737acfc31f53')
yun_pian.send_sms('1862', '18119305139')