以下代码可用于发送消息,但当消息到达时,它会显示文本' VERIFY'对于发件人ID。如何指定发件人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))
答案 0 :(得分:7)
将第三个参数MessageAttributes添加到publish方法。
snsclient.publish(PhoneNumber='+84932575571', Message=theMessage,MessageAttributes={
'AWS.SNS.SMS.SenderID': {
'DataType': 'String',
'StringValue': 'Godzilla'
}})
许多国家/地区不支持发件人ID。见AWS SNS SMS SenderId Supported Countries