在AWS 10DLC(10-digit long code)的实现中,支持跨AWS账号发送消息。以下是实现跨账号发送消息的示例代码:
import boto3
sender_id = 'MY_SENDER_ID'
destination_number = 'DESTINATION_NUMBER'
account_id = 'MY_ACCOUNT_ID'
sns = boto3.client('sns')
response = sns.set_sms_attributes(
attributes={
'DefaultSenderID': sender_id,
'DefaultSMSType': 'Transactional'
}
)
response = sns.publish(
PhoneNumber='+1' + destination_number,
Message='Hello from ' + account_id
)
这样,就可以在两个AWS账号之间发送消息了。