我已经实现了凌空库android。但我收到错误com.android.volley.NoConnectionError: java.io.IOException: Received authentication challenge is null
,网址是http://23.89.192.247/tanker-dev/index.php/api/masuk
,
这是我的代码:
queue = Volley.newRequestQueue(this);
Map<String, String> jsonParams = new HashMap<String, String>();
jsonParams.put("username",user);
jsonParams.put("password", password);
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST,
url,
new JSONObject(jsonParams),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(SplashLoginActivity.this, ""+response,Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(SplashLoginActivity.this, ""+error,Toast.LENGTH_LONG).show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=utf-8");
headers.put("User-agent", "My useragent");
headers.put("WWW-Authenticate", "None");
return headers;
}
};
queue.add(jsonObjReq);
如何解决?对不起我的英文...