【问题标题】:HTTP POST PARAMETERS ENCODING ERROR ANDROIDHTTP POST 参数编码错误 ANDROID
【发布时间】:2013-06-17 16:55:01
【问题描述】:

我正在开发一个 Android 应用程序。 我需要连接到我的 PHP,我正在使用 HttpPost。这是我的代码。我已经遵循了几个教程,但它不起作用。 错误是 PHP 没有收到我从应用程序代码传递的参数。虽然它正确连接到 PHP。 我使用 POSTman 来查找 PHP 中的错误,但它工作正常。 我把我的代码放在这里:

private void httppostconnect(ArrayList<NameValuePair> parametros, String urlwebserver) {
    try {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(urlwebserver);
        httppost.setEntity(new UrlEncodedFormEntity(parametros));
        //ejecuto peticion enviando datos por POST
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();
    } catch(Exception e) {
        Log.e("GetBuscadas", "Error in http connection "+e.toString());
    }
}

【问题讨论】:

    标签: php android http-post androidhttpclient


    【解决方案1】:

    你能澄清一下这些参数是什么,你的“参数”变量。 通常的问题是不发送内容类型标头。

    【讨论】:

    • parametros 包含两个字符串名称值对。你问的是这个吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-12
    • 1970-01-01
    • 2012-01-26
    • 1970-01-01
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    相关资源
    最近更新 更多