Sorry to bother you guys but I have a problem.
Is my fist time developing a php with JSON and also working with a online DB from a Android Device, my problem is that I don't know why my php returns null
a like I haven't send him any variables at all.
My php code is:
<?php
$data = file_get_contents('php://input');
$json = json_decode($data, true);
var_dump($json);
?>
The question is: Which is the way to collect the JSON data that the Android Device has send to my php?
If some one asks that is the way I send the data from my Android Device to the php:
In my android app I send the JSON object this way:
HttpResponse response =null;
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpConnectionParams.setSoTimeout(httpClient.getParams(), 5000);
HttpConnectionParams.setConnectionTimeout(httpClient.getParams(),3000);
HttpPost request = new HttpPost(url);
StringEntity se = new StringEntity(json.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,
"application/json"));
try{
response = httpClient.execute(request);
}catch(SocketException sE)
{
throw sE;
}
Thank you very much and sorry for my bad writing skills
0 comments:
Post a Comment