将参数发送到php时出错

时间:2013-06-28 09:05:28

标签: php android

将android连接到php时有时参数未发送。

user=i.getExtras().getString("user");
params.add(new BasicNameValuePair("user",user));
// getting JSON string from URL
json = jParser.makeHttpRequest(url_orders, "GET", params);

基于空用户获得的结果。

1 个答案:

答案 0 :(得分:0)

  

这对我有用,试试这个:

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://URL.com.php");
postParameters.add(new BasicNameValuePair("param1", value1));
postParameters.add(new BasicNameValuePair("param2", value2));
httppost.setEntity(new UrlEncodedFormEntity(postParameters));
HttpResponse response = httpclient.execute(httppost);
String str = inputStreamToString(response.getEntity().getContent())  
            .toString()