簡體   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 默認使用 OkHttp。

我個人在依賴項上包含了implementation 'com.squareup.okhttp3:okhttp:3.7.0

我這樣使用它:

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

如果您搜索它,您有幾個關於如何發出您想要的請求的教程。

您還可以使用其他更強大的框架,例如最近支持 b Google 的 Volley。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM