示例代码中使用了requests库
示例中验证部分username固定为api,password格式为key-32位KEY,各位的KEY可在后台短信或语音->触发发送下查看、更改
关于requests:
http://cn.python-requests.org/en/latest/index.html
requests安装:
http://cn.python-requests.org/en/latest/user/install.html
# -*- coding: utf-8 -*- import requests; import json; def send_messag_example(): resp = requests.post("http://sms-api.luosimao.com/v1/send.json", auth=("api", "key-eb3829cd732d929feb06556c063010d11"), data={ "mobile": "13761428110", "message": "hello,wolrd【luosimao】" },timeout=3 , verify=False) result = json.loads( resp.content ) print result if __name__ == "__main__": send_messag_example();
{u'msg': u'ok', u'error': 0}
resp = requests.get( "http://sms-api.luosimao.com/v1/status.json" , auth=("api", "key-747fc32dda92665878511bb8e16eb532 "), timeout=5 , verify=False ); print json.loads( resp.content )
{u'deposit': u'808646', u'error': 0}
# -*- coding: utf-8 -*- import requests; import json; def send_messag_example(): resp = requests.post("http://voice-api.luosimao.com/v1/verify.json"), auth=("api", "key-eb3829cd732d929feb06556c063010d11"), data={ "mobile": "13761428110", "code": "123456" },timeout=3 , verify=False) result = json.loads( resp.content ) print result if __name__ == "__main__": send_messag_example();
{u'msg': u'ok', u'error': 0}
resp = requests.get( "http://voice-api.luosimao.com/v1/status.json" , auth=("api", "key-747fc32dda92665878511bb8e16eb532 "), timeout=5 , verify=False ) print json.loads( resp.content )
{u'deposit': u'808646', u'error': 0}