PHP 서버로 발리 라이브러리를 사용하여 json 요청을하려고하는데, 서버가 json 객체를받지 못하는 이유는 무엇입니까? , 빈 문자열로 응답합니다. 여기에 내 코드Android Volley - POST로 비어있는 응답을받을 수없는 POST로 JSON 요청을 수행 할 수 없습니다.
import android.content.Context;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response.Listener;
import com.android.volley.Response.ErrorListener;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
public class MyVolley implements Listener, ErrorListener {
private static Context appContext;
public MyVolley(Context context) {
appContext = context;
}
public void stuff() throws JSONException {
RequestQueue queue = Volley.newRequestQueue(appContext);
JSONObject obj = new JSONObject();
obj.put("param1", "assda");
obj.put("param2", "fassfafsa");
JsonObjectRequest stringRequest = new JsonObjectRequest(Request.Method.POST, "some url here", obj, this, this);
queue.add(stringRequest);
}
@Override
public void onResponse(Object response) {
System.out.println(response);
}
@Override
public void onErrorResponse(VolleyError error) {
System.out.println(error);
}
}
이며 실행시,이 서버가 왜이 일이 될 수
array (
'Content-Type' => 'application/json; charset=utf-8',
'User-Agent' => 'pointless info here',
'Host' => 'some host here',
'Connection' => 'Keep-Alive',
'Accept-Encoding' => 'gzip',
'Content-Length' => '107',
) array (
) array (
)
수신 무엇인가?