无法发送POST请求,参数可能为空

时间:2015-07-07 14:34:51

标签: android

我正在尝试在android中发送POST请求。但我得$ _REQUEST为空。

这是我的代码:

try {

        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitNetwork().build());
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("firstName", firstName));
        nameValuePairs.add(new BasicNameValuePair("lastName", lastName));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);
    } catch (Exception e) {
        e.printStackTrace();
    }

有什么建议吗?

也许我不知道如何获取参数。

在php脚本中,我有这段代码:

error_log(var_export($_REQUEST, true) . "\n", 3, "/Users/christianrusso/Desktop/crusso.log");

请求为空。

0 个答案:

没有答案
相关问题