private void getJson() { RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext()); String httpurl="http://live.jufan.tv/cgi/search/resultlist"; StringRequest stringRequest=new StringRequest(Request.Method.POST, httpurl, new Response.Listener<String>() { @Override public void onResponse(String s) { ss = s; toJson(s); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { } }){ protected Map<String, String> getParams() { //在这里设置需要post的参数 Map<String, String> map = new HashMap<String, String>(); map.put("sign", "05B07785EC472C0DD7155BBC25370527B249AC50"); map.put("userid", "500073885"); map.put("openid", "C6FCDB0A67A0A92791164E49C9A1411A"); map.put("accesstoken","E4A4A5FEFF8CC49824AAAB69AB434352"); map.put("r","hgoid"); map.put("page","0"); map.put("key", str); return map; } }; requestQueue.add(stringRequest); }
okhttp的get请求
OkHttpClient client=new OkHttpClient(); try { n = URLEncoder.encode(name,"UTF-8"); Log.i("cccccccccccccccc",n); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } String path="http://live.jufan.tv/cgi/search/resultlist?sign=7FAD90CE4CBA110D162D0BB153D8424F88B80C9E&userid="+uid+"&openid=FAB8B2BCA97B896125EB421EE9ABB02A&accesstoken=2AEB3C0BD7F9CBA9C2C135098B608E28&r=oftkmkhny&page=0&key="+n; // String path="http://live.jufan.tv/cgi/search/resultlist?sign=7FAD90CE4CBA110D162D0BB153D8424F88B80C9E&userid=500056489&openid=FAB8B2BCA97B896125EB421EE9ABB02A&accesstoken=2AEB3C0BD7F9CBA9C2C135098B608E28&r=oftkmkhny&page=0&key=%E2%80%9C%E5%93%88%E6%AF%94%20%E6%9D%A8%E5%AE%87%E6%97%8B%E2%80%9D"; Log.i("ttttttttttttttttttt",path); //创建一个Request final com.squareup.okhttp.Request request = new com.squareup.okhttp.Request.Builder() .url(path) .build(); Call call=client.newCall(request); //请求加入调度 call.enqueue(new Callback() { @Override public void onFailure(com.squareup.okhttp.Request request, IOException e) { } @Override public void onResponse(com.squareup.okhttp.Response response) throws IOException { String str= response.body().string(); toListjson(str); Log.i("rrrrrrrrrrrrrrr",""+str); } });

被折叠的 条评论
为什么被折叠?



