volley的get,post请求

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);
            }
        });

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值