简体   繁体   English

如何从头开始发出可用于 Oauth 和不同 api 调用的 HTTP 请求的基础知识

[英]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.

相关问题 如何使用HttpURLConnection发出oauth2请求 - How to use HttpURLConnection to make oauth2 request 如何使用带AsynceTask的Oauth 2.0向自定义api发送http请求 - How to send an http request to custom api using Oauth 2.0 with AsynceTask 是否有可用于拨打电话的API? - Is there any API which can be used to make phone calls? 如何从android(java)中的json响应中获取内部索引对象,该对象对rest api调用使用改造 - How to get inner indexed object from json response in android (java) which use retrofit for rest api calls 如何使用HttpClient发出HTTP Get请求,使其看起来类似于来自iPhone的请求 - How can I make HTTP Get request using HttpClient to look similar to a request from iPhone 如何从AsyncTask发出Apache HTTP请求 - How to make Apache HTTP request from AsyncTask 如何从 Android 发出 http 请求? - How to make a http request from Android? 我如何发出HTTP POST请求并使用我应该在android中获得的Json响应 - How can i make an HTTP POST request and and use the Json Response i should get in android 如何进行并行或并发的API调用? - How can i make parallel or concurent API calls? 如何使用 http Web Request 向 API 发送数据? - How to use http Web Request to Send data to API?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM