如何 post json格式的数据,并附加http头,接受返回数据,请看下面的代码:
private void HttpPostData() {
try {
HttpClient httpclient = new DefaultHttpClient();
String uri = "http://www.yourweb.com";
HttpPost httppost = new HttpPost(uri);
//添加http头信息
httppost.addHeader("Authorization", "your token"); //认证token
httppost.addHeader("Content-Type", "application/json");
httppost.addHeader("User-Agent", "imgfornote");
//http post的json数据格式: {"name": "your name","parentId": "id_of_parent"}
JSONObject obj = new JSONObject();
obj.put("name", "your name");
obj.put("p