How to get the data on the HTTP server and append HTTP first class authentication information when getting the data, see the following code:
public void Httpgetdata () {
try {
httpclient httpclient = new Defaulthttpclient ();
String uri = "http://www.yourweb.com";
HttpGet get = new HttpGet (URI);
Add HTTP header information
get.addheader ("Authorization", "Your Token");
Get.addheader ("Content-type", "Application/json");
Get.addheader ("User-agent", "Your Agent");
HttpResponse response;
Response = Httpclient.execute (get);
int code = Response.getstatusline (). Getstatuscode ();
Verify status code if successfully received data if
(code = =) {
//returns JSON format: {"id": "27jpl~j4vsl0lx00e00005", "Version": "ABC"}
String rev. = entityutils.tostring (response.getentity ());
obj = new Jsonobject (rev);
String id = obj.getstring ("id");
String Version = obj.getstring ("version");
}
} catch (Exception e) {
}
}
Main classes used: Org.apache.http.client.HttpClient, Org.apache.http.client.methods.HttpGet and Org.json.JSONObject