boto3 - aws sns - 指定发件人 ID

boto3 - aws sns - specify Sender ID

以下代码用于发送消息,但当它到达时,它会显示发件人 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))

向发布方法添加第三个参数 MessageAttributes。

snsclient.publish(PhoneNumber='+84932575571', Message=theMessage,MessageAttributes={
'AWS.SNS.SMS.SenderID': {
  'DataType': 'String',
  'StringValue': 'Godzilla'   
}})

许多国家/地区不支持发件人 ID。见 AWS SNS SMS SenderId Supported Countries