日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python 阿里云短信接口_阿里云短信PythonSDK的用法

發(fā)布時(shí)間:2025/3/20 python 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 阿里云短信接口_阿里云短信PythonSDK的用法 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

阿里云知識(shí)

阿里云短信PythonSDK的用法

阿里云短信PythonSDK的用法示例代碼 # coding=utf-8 from jdcloud_sdk.core.credential import Credential from jdcloud_sdk.services.sms.client.SmsClient import SmsClient from jdcloud_sdk.services.sms.apis.BatchSendRequest import BatchSendParamete

阿里云短信PythonSDK的用法示例代碼

# coding=utf-8

from jdcloud_sdk.core.credential import Credential

from jdcloud_sdk.services.sms.client.SmsClient import SmsClient

from jdcloud_sdk.services.sms.apis.BatchSendRequest import BatchSendParameters, BatchSendRequest

from jdcloud_sdk.services.sms.apis.StatusReportRequest import StatusReportParameters, StatusReportRequest

from jdcloud_sdk.services.sms.apis.ReplyRequest import ReplyParameters, ReplyRequest

# 地域信息不用修改

regionId = 'cn-north-1'

# 請(qǐng)?zhí)顚懹脩鬭ksk (應(yīng)用管理-概覽 頁面可以查看自己aksk)

access_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

secret_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

credential = Credential(access_key, secret_key)

client = SmsClient(credential)

# 發(fā)送

def testBatchSendMsg():

try:

# 設(shè)置模板Id

templateId = 'bm_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

# 設(shè)置簽名Id

signId = 'qm_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

# 設(shè)置發(fā)送手機(jī)號(hào)

phoneList = ['186xxxxxxxx', '183xxxxxxxx']

parameters = BatchSendParameters(regionId=regionId, templateId=templateId,

signId=signId, phoneList=phoneList)

# 設(shè)置模板參數(shù), 非必填

params = [ ]

parameters.setParams(params=params)

request = BatchSendRequest(parameters)

resp = client.send(request)

if resp.error is not None:

print(resp.error.code, resp.error.message)

print(resp.result)

except Exception as e:

print(e)

# 錯(cuò)誤處理

# 查詢狀態(tài)報(bào)告

def testStatusReport():

try:

# 設(shè)置序列號(hào)。序列號(hào)從下發(fā)接口response中獲取

sequenceNumber = '1227185xxxxxxxxxxxxxx'

parameters = StatusReportParameters(regionId=regionId, sequenceNumber=sequenceNumber)

# 設(shè)置需要獲取回執(zhí)的手機(jī)號(hào)碼列表,非必傳

# phoneList = [ ]

# parameters.setPhoneList(phoneList=phoneList)

request = StatusReportRequest(parameters)

resp = client.send(request)

if resp.error is not None:

print(resp.error.code, resp.error.message)

print(resp.result)

except Exception as e:

print(e)

# 查詢回復(fù)信息

def testReply():

try:

# 設(shè)置應(yīng)用Id

appId = '22ed9c2xxxxxxxxxxxxxxxxxxx'

# 設(shè)置查詢時(shí)間

dataDate = 'xxxx-xx-xx'

parameters = ReplyParameters(regionId=regionId, appId=appId, dataDate=dataDate)

# 設(shè)置查詢手機(jī)號(hào)

phoneList = [ ]

parameters.setPhoneList(phoneList=phoneList)

request = ReplyRequest(parameters)

resp = client.send(request)

if resp.error is not None:

print(resp.error.code, resp.error.message)

print(resp.result)

except Exception as e:

print(e)

if __name__ == '__main__':

# 發(fā)送短信

testBatchSendMsg()

# 查詢狀態(tài)報(bào)告

# testStatusReport()

# 查詢回復(fù)信息

# testReply()

上一篇:阿里云短信javaSDK的用法

下一篇:阿里云短信PHPSDK的用法

總結(jié)

以上是生活随笔為你收集整理的python 阿里云短信接口_阿里云短信PythonSDK的用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。