sns = boto3.client('sns') sns.publish( PhoneNumber = '+11234567890',Message = 'Simple text message' )
根据boto3 documentation,publish方法接受以下参数,
response = client.publish( TopicArn='string',TargetArn='string',PhoneNumber='string',Message='string',Subject='string',MessageStructure='string',MessageAttributes={ 'string': { 'DataType': 'string','StringValue': 'string','BinaryValue': b'bytes' } } )
它需要一个“消息”参数和以下三个参数之一,如文档中所述:
TopicArn (string) — The topic you want to publish to.
If you don’t specify a value for the TopicArn parameter,you must
specify a value for the PhoneNumber or TargetArn parameters.TargetArn (string) — Either TopicArn or EndpointArn,but not both.
If you don’t specify a value for the TargetArn parameter,you must
specify a value for the PhoneNumber or TopicArn parameters.PhoneNumber (string) — The phone number to which you want to deliver
an SMS message. Use E.164 format.If you don’t specify a value for the PhoneNumber parameter,you must
specify a value for the TargetArn or TopicArn parameters.
Unknown parameter in input: “PhoneNumber”,must be one of: TopicArn,
TargetArn,>Message,Subject,MessageStructure,MessageAttributes”.
所以文档似乎表明PhoneNumber是一个有效的参数,但是当使用时,会发生错误,错误的反馈表明PhoneNumber不是可能的参数.我怀疑我缺少一些明显简单的东西,但可以使用一些帮助.
我知道还有其他途径发送短信,如电子邮件网关和其他供应商提供的解决方案,如Twilio,但我想追求基于SNS的路由,并了解我在哪里出错.