gpt4 book ai didi

php - 使用 php 接收 android POST 数据

转载 作者:行者123 更新时间:2023-11-29 18:11:23 26 4
gpt4 key购买 nike

我搜索了一些答案,但找不到任何答案。那么如何使用 PHP 接收和保存从 Android 应用程序使用 POST 发送给它的数据。我目前正在使用以下代码,所以我将使用什么 PHP 来存储数据。有关此教程的任何链接也会有所帮助。

public void send(View v)
{
// get the message from the message text box
String msg = msgTextField.getText().toString();

// make sure the fields are not empty
if (msg.length()>0)
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://kiwigaming.beastnode.net/upload.php");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("Date", "Unitnumber"));
nameValuePairs.add(new BasicNameValuePair("Doneornot", msg));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost);
msgTextField.setText(""); // clear text box
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}

}
else
{
// display message if text fields are empty
Toast.makeText(getBaseContext(),"All field are required",Toast.LENGTH_SHORT).show();
}

}

最佳答案

超全局 $_POST 包含发布数据。

<?php
print_r($_POST);
?>

关于php - 使用 php 接收 android POST 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10460768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com