How to pass the value into php from android?

前端 未结 1 1444
悲&欢浪女
悲&欢浪女 2021-01-29 09:42

I\'m facing problem with passing the value to the php script from android.

I want the questionid to pass into php script url_get_ansurl but I c

1条回答
  •  我在风中等你
    2021-01-29 10:13

    You can use this by POST or GET

        List params = new ArrayList();
        params.add(new BasicNameValuePair("questionid", questionid));
    
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 10000);
            HttpConnectionParams.setSoTimeout(httpParameters, 10000);
            HttpClient httpClientpost = new DefaultHttpClient(httpParameters);
    
            //HttpGet post = new HttpGet(url_request);
            HttpPost post = new HttpPost(url_request);
    
            UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,
                    HTTP.UTF_8);
            post.setEntity(ent);
    
    
            HttpResponse responsePOST = httpClientpost.execute(post);
            HttpEntity resEntity = responsePOST.getEntity();
            String getresponse = EntityUtils.toString(resEntity); //Response from the server
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
    

    0 讨论(0)
提交回复
热议问题