private Document GET(String callName, String callPrefix, AlchemyAPI_Params params) throws IOException, SAXException, ParserConfigurationException, XPathExpressionException { StringBuilder uri = new StringBuilder(); uri.append(_requestUri) .append(callPrefix) .append('/') .append(callName) .append('?') .append("apikey=") .append(this._apiKey); uri.append(params.getParameterString()); URL url = new URL(uri.toString()); HttpURLConnection handle = (HttpURLConnection) url.openConnection(); handle.setDoOutput(true); return doRequest(handle, params.getOutputMode()); }
private Document POST(String callName, String callPrefix, AlchemyAPI_Params params) throws IOException, SAXException, ParserConfigurationException, XPathExpressionException { URL url = new URL(_requestUri + callPrefix + "/" + callName); HttpURLConnection handle = (HttpURLConnection) url.openConnection(); handle.setDoOutput(true); StringBuilder data = new StringBuilder(); data.append("apikey=").append(this._apiKey); data.append(params.getParameterString()); handle.addRequestProperty("Content-Length", Integer.toString(data.length())); DataOutputStream ostream = new DataOutputStream(handle.getOutputStream()); ostream.write(data.toString().getBytes()); ostream.close(); return doRequest(handle, params.getOutputMode()); }