Php 带参数的jsonarray请求
我有一个php Web服务,它使用Php 带参数的jsonarray请求,php,android,android-volley,Php,Android,Android Volley,我有一个php Web服务,它使用json_encode(array(“moviemakers”=>$rows))返回一个json数组。我需要使用参数从android发出json数组请求 我看到了: public JsonArrayRequest(int method, String url, JSONObject jsonRequest, Listener<JSONArray> listener, ErrorListener errorListener) {
json_encode(array(“moviemakers”=>$rows))返回一个json数组。
我需要使用参数从android发出json数组请求
我看到了:
public JsonArrayRequest(int method, String url, JSONObject jsonRequest,
Listener<JSONArray> listener, ErrorListener errorListener) {
super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(),
listener, errorListener);
}
公共JsonArrayRequest(int方法、字符串url、JSONObject jsonRequest、,
监听器监听器,错误监听器(错误监听器){
super(方法,url,(jsonRequest==null)?null:jsonRequest.toString(),
监听器,错误监听器);
}
当我在代码中使用它时,它会生成一个错误有人能告诉我在我的代码中把上面的代码片段放在哪里吗?这里是一个JsonObjectRequest的示例:
private void volleyRequest(String url){
final JsonObjectRequest request = new JsonObjectRequest(url, null, new Response.Listener<JSONObject>(){
@Override
public void onResponse(JSONObject response) {
try {
Log.i(LOG_FLAG, response.toString(4));
//parseJSON
}catch (JSONException e){
//handle exception
}
}
},new Response.ErrorListener(){
@Override
public void onErrorResponse(VolleyError volleyError) {
//handle error
}
});
//adding request into the queue
ApplicationClass.getInstance().addToRequestQueue(request,"someTag");
}
private void截击请求(字符串url){
final JsonObjectRequest=新JsonObjectRequest(url,null,new Response.Listener()){
@凌驾
公共void onResponse(JSONObject响应){
试一试{
Log.i(Log_标志,response.toString(4));
//parseJSON
}捕获(JSONException e){
//处理异常
}
}
},new Response.ErrorListener(){
@凌驾
公共错误响应(截击错误截击错误){
//处理错误
}
});
//将请求添加到队列中
ApplicationClass.getInstance().addToRequestQueue(请求,“someTag”);
}
在这里你可以找到一个关于截击的非常好的教程:
请提供更多信息。你到底试了什么?你的错误信息是什么?此外,您应该尝试格式化您的源代码。请咨询以获得有关如何使用截击的基本了解,而不是发布您不了解的随机代码。谢谢大家。我已经得到了这个问题的答案