短信接口API

# -*- coding: cp936 -*-
#python 27
#xiaodeng
#http://apistore.baidu.com/apiworks/servicedetail/715.html
#短信接口API



import urllib,json,urllib2
#接口地址
url='http://apis.baidu.com/chonry/chonrysms/chonryapi?'#注意问号


#urlParam,url参数
data={'content':'[恩施]您的验证码,请查收,谢谢','mobile':'xxxxxxxx'}
#编码
data=urllib.urlencode(data)
MyUrl=url+data


#header,头部信息
#记住添加头部信息的方法
req=urllib2.Request(MyUrl)
req.add_header('apikey','75ea5c11d0461f15791c1398a05369b7')
resp=urllib2.urlopen(req)
content=resp.read()
print content

 

posted @ 2015-10-23 21:15  Xiao|Deng  阅读(330)  评论(0编辑  收藏  举报