我没有找到任何有关如何替换弃用方法的示例。okhttp3主页上的示例很旧。这是其中之一:
public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
OkHttpClient client = new OkHttpClient();
String post(String url, String json) throws IOException {
RequestBody body = RequestBody.create(JSON, json);
Request request = new Request.Builder()
.url(url)
.post(body)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
Run Code Online (Sandbox Code Playgroud)
如果有人可以解决,请多多帮助。
更新:我正在使用'com.squareup.okhttp3:okhttp:4.0.1'
我在 Telegram 中使用了 20 个机器人,当我想创建超过 20 个机器人时,机器人之父告诉我以下内容:
\n\n我做不到。\n你来找我要 20 多个机器人。但你问的时候并不尊重。你不提供友谊。你甚至不想叫我“Botfather”。
\n\n在电报帮助中我没有找到任何东西,有人知道一些事情。
\n\n谢谢,Mat\xc3\xadas。
\n