|
| 1 | +import io.appwrite.Client; |
| 2 | +import io.appwrite.coroutines.CoroutineCallback; |
| 3 | +import io.appwrite.services.Avatars; |
| 4 | +import io.appwrite.enums.Theme; |
| 5 | +import io.appwrite.enums.Timezone; |
| 6 | +import io.appwrite.enums.Output; |
| 7 | + |
| 8 | +Client client = new Client() |
| 9 | + .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint |
| 10 | + .setProject("<YOUR_PROJECT_ID>") // Your project ID |
| 11 | + .setSession(""); // The user session to authenticate with |
| 12 | + |
| 13 | +Avatars avatars = new Avatars(client); |
| 14 | + |
| 15 | +avatars.getScreenshot( |
| 16 | + "https://example.com", // url |
| 17 | + Map.of( |
| 18 | + "Authorization", "Bearer token123", |
| 19 | + "X-Custom-Header", "value" |
| 20 | + ), // headers (optional) |
| 21 | + 1920, // viewportWidth (optional) |
| 22 | + 1080, // viewportHeight (optional) |
| 23 | + 2, // scale (optional) |
| 24 | + Theme.LIGHT, // theme (optional) |
| 25 | + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15", // userAgent (optional) |
| 26 | + true, // fullpage (optional) |
| 27 | + "en-US", // locale (optional) |
| 28 | + Timezone.AFRICA_ABIDJAN, // timezone (optional) |
| 29 | + 37.7749, // latitude (optional) |
| 30 | + -122.4194, // longitude (optional) |
| 31 | + 100, // accuracy (optional) |
| 32 | + true, // touch (optional) |
| 33 | + List.of("geolocation", "notifications"), // permissions (optional) |
| 34 | + 3, // sleep (optional) |
| 35 | + 800, // width (optional) |
| 36 | + 600, // height (optional) |
| 37 | + 85, // quality (optional) |
| 38 | + Output.JPG, // output (optional) |
| 39 | + new CoroutineCallback<>((result, error) -> { |
| 40 | + if (error != null) { |
| 41 | + error.printStackTrace(); |
| 42 | + return; |
| 43 | + } |
| 44 | + |
| 45 | + System.out.println(result); |
| 46 | + }) |
| 47 | +); |
| 48 | + |
0 commit comments