GET
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("http://www.dvd-shop.com/getDvd");
HttpResponse response = client.execute(request);
// Get the response
BufferedReader rd = new BufferedReader
(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
textView.append(line);
}
URI uri = new URIBuilder(ConfigurationTest.ADMIN_TOOLS_URL)
.addParameter("userID", ConfigurationTest.MLPUser.USERID)
.addParameter("time", "5")
.addParameter("type", ConfigurationTest.SYNC.ACTIVE_SYNC)
.addParameter("semisterId", "")
.addParameter("clientId",
ConfigurationTest.MLPUser.CLIENTID)
.addParameter("clientString",
ConfigurationTest.MLPUser.CLIENTSTRING).build();
HttpResponse response = client.execute(post);
ResponseHandler<String> handler = new BasicResponseHandler();
String body = handler.handleResponse(response);
JSONObject object = new JSONObject(body);
object.get("authValue").toString();
POST
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://www.dvd-shop.com/login");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("registrationid",
"20122"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
No comments:
Post a Comment