如何 获取一个ID为XXXX的json 远程 数据
private String dopost() throws JSONException{
JSONObject jsonObject=new JSONObject();
jsonObject.put("ReleaseID",ReleaseID);
String s=jsonObject.toString();
String result = "你好";
HttpClient client = new DefaultHttpClient();// 开启网络访问客户端
HttpPost httpGet = new HttpPost(url);// 包装一个GET请求
try {
StringEntity se=new StringEntity(s);
httpGet.setEntity(se);
HttpResponse response = client.execute(httpGet);// 客户端请求
int code = response.getStatusLine().getStatusCode();// 获取响应码
if (code == 200) {
InputStream is =response.getEntity().getContent(); // 获取实体内容
result = StreamTools.streamToString(is); // 字节流转字符串
Log.v("mydemo1", "++="+result);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}