zoukankan      html  css  js  c++  java
  • 阿里云短信验证

    开通阿里云短信服务

      申请签名和模板

      下载pythonSDK

    pip install aliyun-python-sdk-core

      设置AK和SK

    发送短信代码

    #!/usr/bin/env python
    #coding=utf-8
    
    from aliyunsdkcore.client import AcsClient
    from aliyunsdkcore.request import CommonRequest
    
    
    AK='xxxxxxxxxx'
    SK='XXXXXXXXXXXXXX'
    client = AcsClient(AK, SK, 'cn-hangzhou')
    
    request = CommonRequest()
    request.set_accept_format('json')
    request.set_domain('dysmsapi.aliyuncs.com')
    request.set_method('POST')
    request.set_protocol_type('https') # https | http
    request.set_version('2017-05-25')
    request.set_action_name('SendSms')
    
    request.add_query_param('RegionId', "cn-hangzhou")
    request.add_query_param('PhoneNumbers', "17337671115")
    request.add_query_param('SignName', "美多商城")
    request.add_query_param('TemplateCode', "SMS_185212884")
    request.add_query_param('TemplateParam', "{"code":890098}")
    
    response = client.do_action(request)
    # python2:  print(response)
    print(str(response, encoding = 'utf-8'))
    复制代码
  • 相关阅读:
    Linux下c++使用pthread库
    一半,一绊
    【codevs3945】 完美拓印
    【poj2942】 Knights of the Round Table
    【bzoj2730】 HNOI2012—矿场搭建
    【poj1177】 Picture
    Tarjan学习笔记
    联赛总结
    【poj3461】 Oulipo
    【csuoj1014】 西湖三人行
  • 原文地址:https://www.cnblogs.com/wanglisen/p/13929770.html
Copyright © 2011-2022 走看看