如何 獲取一個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;
}
2016-04-19
給你我的一個私藏的接口,哈哈,盡情解析吧,望采納http://www.tngou.net/doc/gallery/31