0
我正在使用以下代碼段在POST數據的Android應用程序中工作。如何在php腳本中獲取POSTED數據?
public void postData()
{
try
{
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2/check/justprint.php");
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("id", "jaydeepsinh jadeja"));
nameValuePairs.add(new BasicNameValuePair("password", "00000000000000"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
String text = EntityUtils.toString(response.getEntity());
Log.i("","response = "+text);
}
catch (ClientProtocolException e)
{
Log.e("Error:",e+"");
e.printStackTrace();
}
catch (IOException e)
{
Log.e("Error:",e+"");
e.printStackTrace();
}
}
我的主要要求是在php腳本中獲取這個值並在網頁上顯示。 有沒有辦法做同樣的事情?