如何 獲取一個(gè)ID為XXXX的json 遠(yuǎn)程 數(shù)據(jù)
private String dopost() throws JSONException{
JSONObject jsonObject=new JSONObject();
jsonObject.put("ReleaseID",ReleaseID);
String s=jsonObject.toString();
String result = "你好";
HttpClient client = new DefaultHttpClient();// 開啟網(wǎng)絡(luò)訪問客戶端
HttpPost httpGet = new HttpPost(url);// 包裝一個(gè)GET請(qǐng)求
try {
StringEntity se=new StringEntity(s);
httpGet.setEntity(se);
HttpResponse response = client.execute(httpGet);// 客戶端請(qǐng)求
int code = response.getStatusLine().getStatusCode();// 獲取響應(yīng)碼
if (code == 200) {
InputStream is =response.getEntity().getContent(); // 獲取實(shí)體內(nèi)容
result = StreamTools.streamToString(is); // 字節(jié)流轉(zhuǎn)字符串
Log.v("mydemo1", "++="+result);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
2016-04-19
給你我的一個(gè)私藏的接口,哈哈,盡情解析吧,望采納http://www.tngou.net/doc/gallery/31