糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > python 播放声音 叮咚_Python

python 播放声音 叮咚_Python

时间:2018-12-29 22:46:50

相关推荐

python 播放声音 叮咚_Python

## Python

~~~

#!/usr/local/bin/python

#-*-coding:utf-8-*-

# author: liang yang

# Time: 16-01-15

# Desc: 叮咚云短信http接口的python代码调用示例

# https访问,需要安装 openssl-devel库。apt-get install openssl-devel

import httplib

import urllib

import json

#服务地址

sms_host = ""

#端口号

port = 443

#查账户信息的URI

user_get_uri = "/v1/sms/userinfo"

#发送验证码

send_yzm_uri = "/v1/sms/sendyzm"

#发送语音验证码

send_yyyzm_uri = "/v1/sms/sendyyyzm"

#发送通知

send_tz_uri = "/v1/sms/sendtz"

#发送营销

send_xy_uri = "/v1/sms/sendyx"

def get_user(apikey):

"""

获取用户信息

"""

params = urllib.urlencode({'apikey': apikey})

conn = httplib.HTTPSConnection(sms_host , port=port)

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

conn.request("POST", user_get_uri, params, headers)

response = conn.getresponse()

response_str = response.read()

conn.close()

return response_str

def send_yzm(apikey, content, mobile):

"""

发送验证码

"""

params = urllib.urlencode({'apikey': apikey, 'content': content, 'mobile':mobile})

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

conn = httplib.HTTPSConnection(sms_host, port=port, timeout=30)

conn.request("POST", send_yzm_uri, params, headers)

response = conn.getresponse()

response_str = response.read()

conn.close()

return response_str

def send_yyyzm(apikey, content, mobile):

"""

发送语音验证码

"""

params = urllib.urlencode({'apikey': apikey, 'content': content, 'mobile':mobile})

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

conn = httplib.HTTPSConnection(sms_host, port=port, timeout=30)

conn.request("POST", send_yyyzm_uri, params, headers)

response = conn.getresponse()

response_str = response.read()

conn.close()

return response_str

def send_tz(apikey, content, mobile):

"""

发送通知

"""

params = urllib.urlencode({'apikey': apikey, 'content': content, 'mobile':mobile})

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

conn = httplib.HTTPSConnection(sms_host, port=port, timeout=30)

conn.request("POST", send_tz_uri, params, headers)

response = conn.getresponse()

response_str = response.read()

conn.close()

return response_str

def send_yx(apikey, content, mobile):

"""

发送营销

"""

params = urllib.urlencode({'apikey': apikey, 'content': content, 'mobile':mobile})

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

conn = httplib.HTTPSConnection(sms_host, port=port, timeout=30)

conn.request("POST", send_tz_uri, params, headers)

response = conn.getresponse()

response_str = response.read()

conn.close()

return response_str

if __name__ == '__main__':

#修改为您的apikey. apikey可在官网()登录后获取

apikey = "***************";

#修改为您要发送的手机号

mobile = "***************";

#查账户信息

print(get_user(apikey))

# 发送验证码短信

# 修改为您要发送的短信内容

yzmcontent="【叮咚云】您的验证码是:1234";

#print send_yzm(apikey,yzmcontent,mobile)

# 发送语音验证码短信

# 修改为您要发送的短信内容

yycontent="1234";

print send_yyyzm(apikey,yycontent,mobile)

# 发送通知短信

# 修改为您要发送的短信内容

tzcontent="【叮咚云】您已成功注册叮咚云,请联系支持人员安排对接测试。";

print send_tz(apikey,tzcontent,mobile)

# 发送营销短信

# 修改为您要发送的短信内容,短信末尾必须带有“退订回T”

yxcontent="【叮咚云】您已成功注册叮咚云,请联系支持人员安排对接测试。退订回t";

print send_yx(apikey,yxcontent,mobile)

~~~

如果觉得《python 播放声音 叮咚_Python》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。