zoukankan      html  css  js  c++  java
  • android http中请求访问添加 cookie

    第一种
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("cookie","p1u_id=4eb591e73554db0f4d3300cb656113abfb968ef6b0ee2b5de0a35caa5217c51faa028b453576b35c");
    networkConnection.setHeaderList(map);
    NetworkConnection.ConnectionResult result = networkConnection.execute();

    第二种是用okhttp
    OkHttpClient client = new OkHttpClient();
    String returnData=null;
    com.squareup.okhttp.Request request = new com.squareup.okhttp.Request.Builder()
    .addHeader("cookie", "p1u_id=4eb591e73554db0f4d3300cb656113abfb968ef6b0ee2b5de0a35caa5217c51faa028b453576b35c")
    .url(url)
    .build();
    Response response = null;
    try {
    response = client.newCall(request).execute();
    returnData=response.body().string();
    Log.i("ss", "url is " + url + "_______RETUNRN DATA IS " + returnData);
    } catch (IOException e) {
    e.printStackTrace();
    }
  • 相关阅读:
    js history对象 手机物理返回键
    正则表达式学习整理
    js获得时间new Date()整理
    币值转换
    打印沙漏
    秋季总结
    对我影响最大的三位老师
    我就是我
    秋季学期学习总结
    自我介绍
  • 原文地址:https://www.cnblogs.com/wanqieddy/p/4665516.html
Copyright © 2011-2022 走看看