Reputation: 385
I have created a http post request for connecting with Php server in android. but in server side i cant extract data from the array
this is the code for making http request
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));
In the eclipse i loged all the values.it is printing and i debug "pairs" it will print an array
[locations[0][time]=1375788271891,
locations[0][latitude]=12.966116,
locations[0][longitude]=77.638493,
locations[0][speed]=0.0]
In php i tried to get this data using
$lat=$_POST["latitude"];
$long=$_POST["longitude"];
$speed=$_POST["speed"];
$time=$_POST["time"];
But iam not getting the values. whats the problem? is there aybody can help me..please reply.. Thanx in Advance :)
Upvotes: 1
Views: 908
Reputation: 2059
I have done something like that, I am guessing you know how to send the data to server through php, Try this, in your php,
$lat=$_POST['latitude'];
$long=$_POST['longitude'];
$speed=$_POST['speed'];
$time=$_POST['time'];
Upvotes: 0
Reputation: 10888
You could try and convert your parameters to JSON and then post them to PHP.
Upvotes: 3