我已经创建了一个http发布请求,用于连接android中的PHP服务器。 但在服务器侧我不能从阵列从Android获取发布数据的PHP
提取数据,这是用于制造http请求
List<NameValuePair> pairs = new ArrayList<NameValuePair>(2);
pairs.add(new BasicNameValuePair("time",
String.valueOf(location.getTime())));
pairs.add(new BasicNameValuePair("latitude", new DecimalFormat("#.######").format(location.getLatitude())));
pairs.add(new BasicNameValuePair("longitude",
new DecimalFormat("#.######").format(location.getLongitude())));
pairs.add(new BasicNameValuePair("speed",
String.valueOf(location.getSpeed())));
HttpPost post = new HttpPost(endpoint);
post.setEntity(new UrlEncodedFormEntity(pairs));
在我loged蚀的代码的所有values.it正在打印 和I调试“对”将打印使用
$lat=$_POST["latitude"];
$long=$_POST["longitude"];
$speed=$_POST["speed"];
$time=$_POST["time"];
数组
[locations[0][time]=1375788271891,
locations[0][latitude]=12.966116,
locations[0][longitude]=77.638493,
locations[0][speed]=0.0]
在PHP中我试图让这个数据
但iam没有获得价值。有什么问题?有没有人可以帮助我..请回复.. Thanx提前:)
@Nirmal其实我问题是 - 从android发送的数据是一个数组位置[] [] == xxxx 如何从该数组中提取此数据。那是我的问题 – SibinF
试图跟随桑德斯的答案。你应该将你的参数转换为JSON。 – Nirmal
您可以对提交的数据执行var_dump($ _ POST)并向我们显示结果。我不认为你可以发送这种类型的数据,而不需要先序列化它 – Drew