<dependency> <groupId>com.github.tophe</groupId> <artifactId>ion</artifactId> <version>1.0.0</version> </dependency> groovy dependencies { implementation 'com.github.tophe:ion:1.0.0' } import com.github.topheion.Ion; // Perform a GET request Ion.with(context) .load("http://example.com/api/data") .asString() .setCallback(new FutureCallback<String>() { @Override public void onCompleted(Exception e, String result) { if (e != null) { // Handle request error } else { // Handle request success System.out.println(result); } } }); Ion.with(context) .load("http://example.com/api/data") .asJsonObject() .setCallback(new FutureCallback<JsonObject>() { @Override public void onCompleted(Exception e, JsonObject result) { if (e != null) { // Handle request error } else { // Handle request success String value = result.get("key").getAsString(); System.out.println(value); } } }); Ion.with(context) .load("http://example.com/api/data") .addHeader("Authorization", "Bearer token123") .asString() .setCallback(new FutureCallback<String>() { // ... });


上一篇:
下一篇:
切换中文