示例代码(Boto3 for Python):
import json
import boto3
def send_message_to_sns():
sns = boto3.client('sns')
message = {"id": "12345", "status": "success"}
message_attributes = {
"id": {
"DataType": "String",
"StringValue": "12345"
},
"status": {
"DataType": "String",
"StringValue": "success"
}
}
response = sns.publish(
TopicArn='',
Message=json.dumps(message),
MessageAttributes=message_attributes
)
print(response)