List of usage examples for org.apache.http.client.methods HttpGet HttpGet
public HttpGet()
From source file:com.tweetlanes.android.urlservice.tweetmarker.TweetMarkerAPI.java
public static HttpResponse getRequest(String url, String debugName) { HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(); request.addHeader("X-Auth-Service-Provider", TwitterApi.TWITTER_VERIFY_CREDENTIALS_JSON); request.addHeader("X-Verify-Credentials-Authorization", TwitterManager.get().generateTwitterVerifyCredentialsAuthorizationHeader()); HttpResponse response = null;//from w w w . j a v a2 s . com try { request.setURI(new URI(url)); //Log.d("tweetlanes url fetch", url); response = client.execute(request); //Log.d(TAG, debugName + " complete"); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return response; }
From source file:com.cse.Controller.PermissionHolder.java
public static void revokePermissions(String... permisionString) { // String url="https://facebook.com/" DefaultHttpClient client = new DefaultHttpClient(); HttpGet getReq = new HttpGet(); }
From source file:com.tinyhydra.botd.GoogleOperations.java
public static List<JavaShop> GetShops(Handler handler, Location currentLocation, String placesApiKey) { // Use google places to get all the shops within '500' (I believe meters is the default measurement they use) // make a list of JavaShops and pass it to the ListView adapter List<JavaShop> shopList = new ArrayList<JavaShop>(); try {/*from w w w . j a v a2 s. co m*/ HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(); int accuracy = Math.round(currentLocation.getAccuracy()); if (accuracy < 500) accuracy = 500; request.setURI(URI.create("https://maps.googleapis.com/maps/api/place/search/json?location=" + currentLocation.getLatitude() + "," + currentLocation.getLongitude() + "&radius=" + accuracy + "&types=" + URLEncoder.encode("cafe|restaurant|food", "UTF-8") + "&keyword=coffee&sensor=true&key=" + placesApiKey)); HttpResponse response = client.execute(request); BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer sb = new StringBuffer(""); String line = ""; while ((line = in.readLine()) != null) { sb.append(line); } JSONObject predictions = new JSONObject(sb.toString()); // Google passes back a status string. if we screw up, it won't say "OK". Alert the user. String jstatus = predictions.getString("status"); if (jstatus.equals("ZERO_RESULTS")) { Utils.PostToastMessageToHandler(handler, "No shops found in your area.", Toast.LENGTH_SHORT); return shopList; } else if (!jstatus.equals("OK")) { Utils.PostToastMessageToHandler(handler, "Error retrieving local shops.", Toast.LENGTH_SHORT); return shopList; } // This section may fail if there's no results, but we'll just display an empty list. //TODO: alert the user and cancel the dialog if this fails JSONArray ja = new JSONArray(predictions.getString("results")); for (int i = 0; i < ja.length(); i++) { JSONObject jo = (JSONObject) ja.get(i); shopList.add(new JavaShop(jo.getString("name"), jo.getString("id"), "", jo.getString("reference"), jo.getString("vicinity"))); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return shopList; }
From source file:com.github.restdriver.serverdriver.http.RequestTimeoutTest.java
@Test public void timeoutIsAppliedCorrectlyToRequest() { ServerDriverHttpUriRequest request = new ServerDriverHttpUriRequest(new HttpGet()); RequestTimeout timeout = new RequestTimeout(1111, 2222); timeout.applyTo(request);/*from w w w . j av a 2 s . c om*/ assertThat(request.getConnectionTimeout(), is(1111L)); assertThat(request.getSocketTimeout(), is(2222L)); }
From source file:com.github.restdriver.serverdriver.http.RequestSocketTimeoutTest.java
@Test public void timeoutIsAppliedCorrectlyToRequest() { ServerDriverHttpUriRequest request = new ServerDriverHttpUriRequest(new HttpGet()); RequestSocketTimeout timeout = new RequestSocketTimeout(1111); timeout.applyTo(request);// w w w .j a va 2s. c o m assertThat(request.getSocketTimeout(), is(1111L)); }
From source file:com.github.restdriver.serverdriver.http.RequestConnectionTimeoutTest.java
@Test public void timeoutIsAppliedCorrectlyToRequest() { ServerDriverHttpUriRequest request = new ServerDriverHttpUriRequest(new HttpGet()); RequestConnectionTimeout timeout = new RequestConnectionTimeout(1111); timeout.applyTo(request);//www.j a va 2 s . com assertThat(request.getConnectionTimeout(), is(1111L)); }