http json 怎么传过去
展开全部
试试这个代码:Button show_data;JSONObject my_json_obj;String path,firstname,lastname;path = " http://192.168.101.123:255/services/services.php?id=9"; HttpClient client = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); HttpEntity entity; HttpResponse response = null; HttpURLConnection urlconn; my_json_obj = new JSONObject(); try { urlconn = (HttpURLConnection) new URL(path).openConnection(); urlconn.setConnectTimeout(10000); urlconn.setDoOutput(true); OutputStreamWriter writer = new OutputStreamWriter(urlconn.getOutputStream(), "UTF-8");my_json_obj.put("sUserName", "test2"); my_json_obj.put("sPassword", "123456");writer.write(my_json_obj.toString()); writer.close();if(true) { String temp; temp = WebRequestCall(my_json_obj); //Log.i("Reply", temp); }
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询