/** * Fetches the top ten selling titles from the Product Advertising API. * * @throws SpeechletException */ private List<String> fetchTitles(String category) throws SpeechletException { List<String> titles = new LinkedList<String>(); try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); // Make the actual http call and get the xml response. Document doc = db.parse(getRequestUrl(category)); NodeList nodeList = doc.getElementsByTagName("Title"); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); titles.add(node.getTextContent()); } } catch (Exception e) { throw new SpeechletException(e); } return titles; }
/** * Fetches the top ten selling titles from the Product Advertising API. * * @throws SpeechletException */ private List<String> fetchTitles(String category) throws SpeechletException { List<String> titles = new LinkedList<String>(); try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); // Make the actual http call and get the xml response. Document doc = db.parse(getRequestUrl(category)); NodeList nodeList = doc.getElementsByTagName("Title"); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); titles.add(node.getTextContent()); } } catch (Exception e) { throw new SpeechletException(e); } return titles; }
return Response.bye(session); default: throw new SpeechletException("Invalid Intent: " + intentName);