我已从AWS Pinpoint
. 我已经sms
为它启用了两种方式。并尝试发送TRANSACTIONAL
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'])