List of usage examples for org.apache.http.message BasicNameValuePair getValue
public String getValue()
From source file:de.csw.expertfinder.mediawiki.api.MediaWikiAPI.java
/** * Performs a request to the http mediawiki api. returns the xml response * encapsulated in a {@link Document} object. * // www .jav a 2 s .com * @param action the action * @param params * @return * @throws MediaWikiAPIException */ Document queryMediaWiki(String action, BasicNameValuePair[] params) throws MediaWikiAPIException { StringBuilder url = new StringBuilder(apiURL); url.append("?action="); url.append(action); url.append("&format=xml"); try { for (BasicNameValuePair param : params) { url.append('&'); url.append(URLEncoder.encode(param.getName(), "UTF-8")); url.append('='); url.append(URLEncoder.encode(param.getValue(), "UTF-8")); } } catch (UnsupportedEncodingException e1) { throw new MediaWikiAPIException("The UTF-8 character encoding is not supported on this platform.", e1); } return httpRequest(url.toString()); }
From source file:com.groupon.odo.client.Client.java
protected String doGet(String apiUrl, BasicNameValuePair[] data) throws Exception { String fullUrl = BASE_URL + apiUrl; if (data != null) { if (data.length > 0) { fullUrl += "?"; }//from w w w . j ava 2 s . com for (BasicNameValuePair bnvp : data) { fullUrl += bnvp.getName() + "=" + uriEncode(bnvp.getValue()) + "&"; } } // add clientUUID if necessary if (_clientId != null) { if (data == null || data.length == 0) { fullUrl += "?"; } fullUrl += "clientUUID=" + _clientId; } fullUrl += "&profileIdentifier=" + uriEncode(this._profileName); HttpGet get = new HttpGet(fullUrl); HttpClient client = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(client.getParams(), _timeout); HttpConnectionParams.setSoTimeout(client.getParams(), _timeout); HttpResponse response = client.execute(get); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String accumulator = ""; String line = ""; while ((line = rd.readLine()) != null) { accumulator += line; accumulator += "\n"; } return accumulator; }
From source file:com.groupon.odo.client.Client.java
protected String doDelete(String apiUrl, BasicNameValuePair[] data) throws Exception { String fullUrl = BASE_URL + apiUrl; if (data != null) { if (data.length > 0) { fullUrl += "?"; }//from www . ja v a2s .com for (BasicNameValuePair bnvp : data) { fullUrl += bnvp.getName() + "=" + uriEncode(bnvp.getValue()) + "&"; } } // add clientUUID if necessary if (_clientId != null) { if (data == null || data.length == 0) { fullUrl += "?"; } fullUrl += "clientUUID=" + _clientId; } fullUrl += "&profileIdentifier=" + uriEncode(this._profileName); HttpDelete get = new HttpDelete(fullUrl); HttpClient client = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(client.getParams(), _timeout); HttpConnectionParams.setSoTimeout(client.getParams(), _timeout); HttpResponse response = client.execute(get); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); String accumulator = ""; String line = ""; while ((line = rd.readLine()) != null) { accumulator += line; accumulator += "\n"; } return accumulator; }