Vie*_*ank 0 amazon-web-services amazon-sns boto3
以下代码用于发送消息,但是当它到达时,它会显示发件人ID的文本"VERIFY".如何指定发件人ID?我认为这是使用消息属性完成的,但我无法弄清楚语法.
session = boto3.session.Session(profile_name='Credentials',region_name='us-east-1')
theMessage='Now is the time for all good people to come to the aid of their party'
senderID='Godzilla'
snsclient = session.client('sns')
response = snsclient.publish(PhoneNumber='+84932575571', Message=theMessage)
pp = pprint.PrettyPrinter(indent=4)
print(pp.pprint(response))
Run Code Online (Sandbox Code Playgroud)
将第三个参数MessageAttributes添加到publish方法.
snsclient.publish(PhoneNumber='+84932575571', Message=theMessage,MessageAttributes={
'AWS.SNS.SMS.SenderID': {
'DataType': 'String',
'StringValue': 'Godzilla'
}})
Run Code Online (Sandbox Code Playgroud)
许多国家/地区不支持发件人ID.请参阅AWS SNS SMS SenderId支持的国家/地区
归档时间: |
|
查看次数: |
425 次 |
最近记录: |