안드로이드 응용 프로그램은 문제없이 JSON 개체를 보내는 것 같아하지만 난받을 때 내가 얻을 :앱에서 JSON 데이터를 수신 할 수 없습니다
"공지 사항 : 정의되지 않은 인덱스를"
개체를 보내는 코드가 여기에 있습니다 :
public void sendJson(String name1, String name2) throws JSONException {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://example.com/JSON_FOLDER/JSON2/parseData.php");
HttpResponse response;
JSONObject json = new JSONObject();
try {
json.put("name1", name1);
json.put("name2", name2);
StringEntity se = new StringEntity(json.toString());
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
httppost.getParams().setParameter("json", json); // new code
//Execute HTTP POST request
httppost.setEntity(se);
response = httpclient.execute(httppost);
if(response != null) {
str = inputStreamToString(response.getEntity().getContent()).toString();
Log.i("DATA", "Data send== " + str);
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
서버 측에서
:
$json = $_POST['name1'];
$decoded = json_decode($json, TRUE);
와 나는 정의되지 않은 인덱스 통지를 얻었다.
내가 서버 나 클라이언트 측에서 중, 당신이 대답 원시 결과를 살펴 보시기 바랍니다. – arkascha
처럼 : *** file_get_contents ('php : // input'); *** 시도했지만 결과가 없습니다 – t0s
당신은 로그 파일 (예 : PHP syslog())에 응답을 덤프하는 서버쪽에 있습니다. 클라이언트 측에서 : 귀하의 플랫폼에 따라 달라집니다, 나는 안드로이드를 모른다. 아마도 Wireshark와 같은 네트워크 스니퍼를 사용하는 것이 가장 쉽습니다. – arkascha