use of software.amazon.awssdk.services.pinpointsmsvoice.PinpointSmsVoiceClient in project aws-doc-sdk-examples by awsdocs.
the class SendNotifications method handleVoiceMessage.
public String handleVoiceMessage(String myDom) throws JDOMException, IOException {
String mobileNum = "";
List<String> listVal = new ArrayList<>();
listVal.add("application/json");
Map<String, List<String>> values = new HashMap<>();
values.put("Content-Type", listVal);
ClientOverrideConfiguration config2 = ClientOverrideConfiguration.builder().headers(values).build();
PinpointSmsVoiceClient client = PinpointSmsVoiceClient.builder().overrideConfiguration(config2).region(Region.US_EAST_1).build();
SAXBuilder builder = new SAXBuilder();
Document jdomDocument = builder.build(new InputSource(new StringReader(myDom)));
org.jdom2.Element root = jdomDocument.getRootElement();
// get a list of children elements.
List<org.jdom2.Element> students = root.getChildren("Student");
for (org.jdom2.Element element : students) {
mobileNum = element.getChildText("Phone");
sendVoiceMsg(client, mobileNum);
}
client.close();
return mobileNum;
}
use of software.amazon.awssdk.services.pinpointsmsvoice.PinpointSmsVoiceClient in project aws-doc-sdk-examples by awsdocs.
the class SendVoiceMessage method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + "SendVoiceMessage <originationNumber> <destinationNumber> \n\n" + "Where:\n" + " originationNumber - the phone number or short code that you specify has to be associated with your Amazon Pinpoint account. For best results, specify long codes in E.164 format (for example, +1-555-555-5654). " + " destinationNumber - the recipient's phone number. For best results, you should specify the phone number in E.164 format (for example, +1-555-555-5654). ";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String originationNumber = args[0];
String destinationNumber = args[1];
System.out.println("Sending a voice message");
// Set the content type to application/json
List<String> listVal = new ArrayList<>();
listVal.add("application/json");
Map<String, List<String>> values = new HashMap<>();
values.put("Content-Type", listVal);
ClientOverrideConfiguration config2 = ClientOverrideConfiguration.builder().headers(values).build();
PinpointSmsVoiceClient client = PinpointSmsVoiceClient.builder().overrideConfiguration(config2).region(Region.US_EAST_1).build();
sendVoiceMsg(client, originationNumber, destinationNumber);
client.close();
}
Aggregations