码迷,mamicode.com
首页 > Web开发 > 详细

OkHttp 常用

时间:2018-12-27 13:14:18      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:arm   常用   http   request   return   har   nbsp   htm   add   

get:

String url = "";
Request request = new Request.Builder() .url(url) .build();
Response response = client.newCall(request).execute();
return okHttpClient.newCall(request).execute().body().string();

 

post:

RequestBody requestBody = new FormBody.Builder().add("key1", value1).add("key2", value2).build();

String url = "http://client.godcharm.com/lottery/do_copy_operation.htm";
OkHttpClient okHttpClient = new OkHttpClient();

Request request = new Request.Builder().url(url).post(requestBody).build();
return okHttpClient.newCall(request).execute().body().string();

OkHttp 常用

标签:arm   常用   http   request   return   har   nbsp   htm   add   

原文地址:https://www.cnblogs.com/pzyin/p/10184233.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!