[英]Basics of how to make HTTP request from ground up which can be use for Oauth and diiferent api calls
有像 Retrofit 这样的框架,但我想学习基础知识,并且有很多可用的类,而且令人困惑,如果可用,请提及一些参考资料。
Retrofit uses OkHttp as default. Retrofit 默认使用 OkHttp。
I personally include implementation 'com.squareup.okhttp3:okhttp:3.7.0
on dependencies我个人在依赖项上包含了implementation 'com.squareup.okhttp3:okhttp:3.7.0
and I use it this way:我这样使用它:
private Response post(String url, String body) throws IOException {
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), body);
Request request = new Request.Builder().url(url).post(requestBody).build();
return <yourOkHttpClient>.newCall(request).execute();
}
You have several tutorials on how to make the requests you want if you search for it.如果您搜索它,您有几个关于如何发出您想要的请求的教程。
You also have other, more robust frameworks, like Volley that is recently supported b Google, which you can use.您还可以使用其他更强大的框架,例如最近支持 b Google 的 Volley。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.