jsonstringを送信しているという問題に直面していますが、文字列が空です。
このphpコードを使用して、文字列を受信しているかどうか、および取得したものを確認すると、次のようになります。
POST:
Array
(
)
GET:
Array
(
[data] =>
)
これは私のAndroidコードです:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.myserver.nl/locatie.php?data=");
httppost.setHeader("Content-type", "application/json");
// Create json object here...
json = new JSONObject();
try {
json.put("id", "0612838");
json.put("longitude", "-143.406417");
json.put("latitude", "32.785834");
json.put("timestamp", "10-10 07:56");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/// create StringEntity with current json obejct
try {
se = new StringEntity(json.toString());
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httppost.setEntity(se);
try {
response = httpclient.execute(httppost);
String temp = EntityUtils.toString(response.getEntity());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
誰かが私が間違っていることを見ていますか?