Skip to content

Instantly share code, notes, and snippets.

@arschles
Created May 25, 2012 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arschles/2790041 to your computer and use it in GitHub Desktop.
Save arschles/2790041 to your computer and use it in GitHub Desktop.
HttpService Async GET Requests
@Override
public ResponseToProcess execute(ProcessedAPIRequest request, SDKServiceProvider provider) {
String url1 = "http://www.bing.com/search?q=kawasaki+ninja";
GetRequest req1 = new GetRequest(url1);
String url2 = "http://www.bing.com/search?q=honda+nighthawk";
GetRequest req2 = new GetRequest(url2);
String url3 = "http://www.bing.com/search?q=bmw+1300s";
GetRequest req3 = new GetRequest(url3);
HttpService http = provider.getHttpService();
Future<HttpResponse> resp1 = http.getAsync(req1);
Future<HttpResponse> resp2 = http.getAsync(req2);
Future<HttpResponse> resp3 = http.getAsync(req3);
Map<String, String> = new HashMap<String, String>();
map.put("kawasaki_ninja_results", resp1.get.getBody());
map.put("honda_nighthawk_results", resp2.get.getBody());
map.put("bmw_1300s_results", resp3.get.getBody());
return new ResponseToProcess(HttpURLConnection.HTTP_OK, map);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment