基于python的短信接口调用代码示例模板

来源:互联网 发布:唐望 知乎 编辑:程序博客网 时间:2024/05/21 17:01

阅信短信验证码平台最近会从新梳理基于不同语言的短信接口调用代码示例,是为了迎合市面上现在流行的各个语言代码实现,也是为了能够更好的服务满足客户的不同层次的需求。

         下面的代码是基于python的短信接口调用代码示例模板,客户可拿来直接使用。

#coding=utf-8

import urllib

import urllib2

import time

import hashlib

 

 

def md5(str):

    import hashlib

m =hashlib.md5()  

m.update(str)

returnm.hexdigest()

 

url ='http://IP/端口'

timenew=time.strftime("%Y%m%d%H%M%S", time.localtime(time.time()))

pwd = md5('**********'+timenew)

values ={'name':'syncs','pwd':pwd,'content':'【阅信短信平台】验证码888888,千万不能告诉别人哦。','phone':'13381272353','subid':'','mttime':timenew}

data =urllib.urlencode(values)

req =urllib2.Request(url, data)

response =urllib2.urlopen(req)

the_page =response.read()

print the_page

 

0 0
原创粉丝点击