我用JSON从android发送数据到php。为此,我使用的代码如下我的代码不能用于发送数据到php
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://futuretime.in/reg.php");
httppost.setHeader("content-type", "application/json");
JSONObject dataJson = new JSONObject();
dataJson.put("password", password);
dataJson.put("number", Integer.parseInt("5556"));
StringEntity entity = new StringEntity(dataJson.toString());
httppost.setEntity(entity);
HttpResponse response = httpclient.execute(httppost);
text=response.toString();
当我excuted这我得到一个消息,如:org.apache.http.message.basichttpresponse 4fb06e5e
我应该如何传递数据 – user3481084
您需要追加你的数据到网址,在你的情况下你的发送密码和数字,所以你应该这样发送 String basicUrl =“http://futuretime.in/reg.php”; String url = basicUrl +“?<你的php文件中的密码变量名> =”+ <你的密码> +“&<你的php文件中的变量名> =”+; getUrlData(url); –