Android HTTP在webserver / log上没有参数:GET

时间:2014-03-03 12:41:20

标签: android http

我正在尝试从Android到我的网络服务器创建异步任务。但我在PHP方面没有参数。在观察我的服务器的日志文件时,它不是POST而是GET。为什么它是GET以及我们为什么没有数据?谢谢!

    public void postData() {
    // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");

    try {
    // Add your data
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new BasicNameValuePair("id", "12345"));
    nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

    // Execute HTTP Post Request
    HttpResponse response = httpclient.execute(httppost);

    } catch (ClientProtocolException e) {
    // TODO Auto-generated catch block
    } catch (IOException e) {
    // TODO Auto-generated catch block
    }
    } 

0 个答案:

没有答案
相关问题