AWS专用长代码号无法发送短信

时间:2019-05-25 10:40:53

标签: amazon-web-services sms amazon-sns aws-pinpoint

我已从AWS Pinpoint请求一个专用的长代码号。我为此启用了两种方法sms。并尝试将TRANSACTIONAL SMS发送到一个号码,尽管SMS正在接收,但是它们不是来自我专用的长代码,而是来自默认的senderId IM-NOTICE

我尝试过的示例Python代码:

region = "ap-south-1"

originationNumber = "+91xxxxxxxxxx"

destinationNumber = "+91xxxxxxxxxx"

message = ("This is a sample message sent from Amazon Pinpoint by using the "
           "AWS SDK for Python (Boto 3).")

applicationId = "xxxxxxxxxxxxxxxxx"

messageType = "TRANSACTIONAL"

registeredKeyword = "xxxxxx"

senderId = "MySenderID"

client = boto3.client('pinpoint',
                      aws_access_key_id='AKIAIVXXXXXXKHXXXXP33RWFHLNXXXXXXXYYA',
                      aws_secret_access_key='XXXUPbs6Kj6O2iXXXXXXXXXXXXXXX',
                      region_name=region)
try:
    response = client.send_messages(
        ApplicationId=applicationId,
        MessageRequest={
            'Addresses': {
                destinationNumber: {
                    'ChannelType': 'SMS'
                }
            },
            'MessageConfiguration': {
                'SMSMessage': {
                    'Body': message,
                    'Keyword': registeredKeyword,
                    'MessageType': messageType,
                    'OriginationNumber': originationNumber,
                    'SenderId': senderId
                }
            }
        }
    )

except ClientError as e:
    print(e.response['Error']['Message'])
else:
    print("Message sent! Message ID: "
          + response['MessageResponse']['Result'][destinationNumber]['MessageId'])

0 个答案:

没有答案