【问题标题】:Use AWS SMS Messaging to send Transaction SMS using python使用 AWS SMS Messaging 使用 python 发送 Transaction SMS
【发布时间】:2019-10-25 18:42:09
【问题描述】:

我正在尝试使用 AWS SNS 将消息发布到移动终端节点,但是有两种类型的消息:促销(默认)和更可靠的交易。

我在设置 SNS 客户端的属性时遇到问题,以便所有消息都是事务性的,以确保将消息传递到手机。如果有人可以帮助我解决这个问题,我将不胜感激。以下是我的代码:

SMSAWSClient = boto3.client(
    "sns",
    aws_access_key_id="My Key",
    aws_secret_access_key="My Secret Key",
    region_name="us-east-1"
)

SMSAWSClient.set_sms_attributes(
    attributes={
        'DefaultSMSType': 'Transactional'
    }
)

现在,当我运行程序时,出现以下错误:

“botocore.errorfactory.InvalidParameterException:调用SetSMSAttributes操作时发生错误(InvalidParameter):无效参数:”

这是我用来发布消息的代码:

SMSAWSClient.publish(PhoneNumber="Phone Number",Message="Message Body")

提前致谢。

【问题讨论】:

  • 为什么'DefaultSMSType ' Transactional 之后也有一个杂散空间?
  • 对不起。我删除了多余的空间,但仍然无法正常工作。

标签: python amazon-web-services aws-sdk boto3 amazon-sns


【解决方案1】:

在一行上设置属性

SMSAWSClient.set_sms_attributes(attributes={'DefaultSMSType': 'Transactional'})

SMSAWSClient.set_sms_attributes(attributes={'DefaultSenderID': 'Sender', 'DefaultSMSType': 'Transactional' })        

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 2016-12-09
    • 1970-01-01
    • 2021-04-29
    • 1970-01-01
    • 2010-12-21
    • 1970-01-01
    相关资源
    最近更新 更多