1.  HttpPost request = new HttpPost(url);   
  2. // 先封装一个 JSON 对象   
  3. JSONObject param = new JSONObject();   
  4. param.put("name""rarnu");   
  5. param.put("password""123456");   
  6. // 绑定到请求 Entry   
  7. StringEntity se = new StringEntity(param.toString());    
  8. request.setEntity(se);   
  9. // 发送请求   
  10. HttpResponse httpResponse = new DefaultHttpClient().execute(request);   
  11. // 得到应答的字符串,这也是一个 JSON 格式保存的数据   
  12. String retSrc = EntityUtils.toString(httpResponse.getEntity());   
  13. // 生成 JSON 对象   
  14. JSONObject result = new JSONObject( retSrc);   
  15. String token = result.get("token");   

还不错!