【发布时间】:2014-04-02 05:33:34
【问题描述】:
这是我用来发送到网站中我的 php 文件的我的 android 代码。还修改了android清单文件。
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(7);
nameValuePairs.add(new BasicNameValuePair("number", "5556"));
nameValuePairs.add(new BasicNameValuePair("password",password));
nameValuePairs.add(new BasicNameValuePair("token",token));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://futuretime.in/post.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
这是我的 php 脚本,用于从 android 接收数据。 但我的问题是当我在 php 中打印数据时,它没有显示任何值。
<?php
$number= $_POST['number'];
$password = $_POST['password'];
$token = $_POST['token'];
echo $number;
?>
【问题讨论】:
-
您的问题是什么?你有什么错误吗?
-
你到底想做什么???
-
可以通过JSON解析发送数据。小参考是stackoverflow.com/a/22686616/3360307
-
从客户端调用时无法在 php 中回显数据,从 android 调用时将数据保存在某处,然后查看是否接收到它
-
if (!empty($_POST)) {$number= $_POST['number']; $password = $_POST['密码']; $token = $_POST['token']; echo $number;}else{echo "Empty";} 试试这个并检查您的帖子是否为空。然后您可以确定错误在哪里。