我正在将联系人添加到活动的活动 api,但请求没有发送帖子参数。参数是从邮递员发送的,但凌空它不起作用。我也尝试从构造函数发送参数,但没有进展。这是代码。
Map<String, String> params = new HashMap();
params.put("email", "wff@dd.com");
params.put("p[1]", "1");
//JSONObject parameters = new JSONObject(params);
RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
url="https://brumano.api-us1.com/admin/api.php?api_key=key&api_action=contact_add&api_output=json";
Log.d("url",url);
JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.POST,url,null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d("url",response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
Log.d("url",error.toString());
error.printStackTrace();
}
}){
@Override
public byte[] getBody() {
HashMap<String, String> params2 = new HashMap<String, String>();
params2.put("email", "w@sss.com");
params2.put("p[1]", "1");
return new JSONObject(params2).toString().getBytes();
}
@Override
public String getBodyContentType() {
return "application/x-www-form-urlencoded;";
}
@Override
protected Map<String, String> getParams() {
Map<String, String> params2 = new HashMap<String, String>();
params2.put("email", "w@sss.com");
params2.put("p[1]", "1");
return params2;
}
}
};
queue.add(jsObjRequest);