小编Dan*_*ers的帖子

从PHP文件接收HTTP POST回应响应(发送POSTS工作正常,这是我无法弄清楚的接收)

所以标题表明我的问题是得到了我正在制作的HTTP POST的响应.应该发生的是我发送了一堆变量,PHP检查数据库,然后向我发送结果(作为页面的回显).

这是android代码:

 public class CheckChallenge extends AsyncTask<String, Void, String> 
  {
    @Override
    protected String doInBackground(String... urls) 
    {
      String response = "";
      try
      {
        URL = urls[0];
   ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4);
   nameValuePairs.add(new BasicNameValuePair("victim",NetPlay.myId)); 
   // need to return these to an array
   nameValuePairs.add(new BasicNameValuePair("rival",rivalid));


        nameValuePairs.add(new BasicNameValuePair("word","null"));
        nameValuePairs.add(new BasicNameValuePair("won","0"));

          HttpClient httpclient = new DefaultHttpClient();
          HttpPost httppost = new      
          HttpPost("http://www.hanged.comli.com/check-rival.php");
          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

          HttpResponse execute = httpclient.execute(httppost);
          HttpEntity entity = execute.getEntity();

          //InputStream is = entity.getContent();

          //mText.setText(is.toString());

         Log.i("postData", execute.getStatusLine().toString());
         //HttpEntity entity = response.getEntity();

      }
      catch(Exception …
Run Code Online (Sandbox Code Playgroud)

php java android http-post echo

4
推荐指数
1
解决办法
6483
查看次数

标签 统计

android ×1

echo ×1

http-post ×1

java ×1

php ×1