我想看看一個PHP腳本寫錯了什麼。該腳本從android應用程序獲取信息,然後使用該數據搜索表併發回信息。該客戶端是這樣寫的:如何發送網址中的數據以測試php文件?
nameValuePairs.add(new BasicNameValuePair("num1", num1));
nameValuePairs.add(new BasicNameValuePair("num2", num2));
nameValuePairs.add(new BasicNameValuePair("num3", num3));
nameValuePairs.add(new BasicNameValuePair("num4", num4));
InputStream is = null;
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.0.4/xampp/phpfile.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
我如何格式化的URL在瀏覽器中,如果我想要執行相同的腳本傳遞NUM1,NUM2,NUM3和num4以同樣的方式?
可以使用curl命令行工具。在這裏試着給看看[此處輸入鏈接的描述] [1] [1]:http://superuser.com/questions/149329/how-do-i-make-a-post-request -with-the-curl-command-line-tool – fedepaol 2012-01-27 18:11:13
'http://10.0.0.4/xampp/phpfile.php?num1 = num1&num2 = num2&num3 = num3&num4 = num4' - 但這可能不起作用,因爲代碼上面使用POST和URL中傳遞的數據是GET。如果您想在瀏覽器中使用Firefox,您需要使用[Poster](https://addons.mozilla.org/en-US/firefox/addon/poster/)或其他類似的工具。 – DaveRandom 2012-01-27 18:12:37