| 4 | |
| 5 | // snippet-start:[sns.java.publish_sms_to_topic.main] |
| 6 | public static void main(String[] args) { |
| 7 | AmazonSNSClient snsClient = new AmazonSNSClient(); |
| 8 | |
| 9 | String topicArn = createSNSTopic(snsClient); |
| 10 | String phoneNumber = "+1XXX5550100"; |
| 11 | // Specify a protocol of "sms" when subscribing a phone number. |
| 12 | subscribeToTopic(snsClient, topicArn, "sms", phoneNumber); |
| 13 | |
| 14 | String message = "My SMS message"; |
| 15 | Map<String, MessageAttributeValue> smsAttributes = |
| 16 | new HashMap<String, MessageAttributeValue>(); |
| 17 | addMessageAttributes(smsAttributes) |
| 18 | sendSMSMessageToTopic(snsClient, topicArn, message, smsAttributes); |
| 19 | } |
| 20 | // snippet-end:[sns.java.publish_sms_to_topic.main] |
| 21 | |
| 22 | // snippet-start:[sns.java.publish_sms_to_topic.create_topic] |