This is an API wrapper for https://whats-th.is/ written in Java. This wrapper requires Java 7 or above to function, it has also been confirmed working with Android (Minimum version is Marshmallow, because of Java 7).
Replace
VERSION
with a specific version. The latest version can be found at the top of the readme Maven:
<dependencies>
<dependency>
<groupId>me.bramhaag</groupId>
<artifactId>owo-java</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>
Gradle:
repositories {
jcenter()
}
dependencies {
compile 'me.bramhaag:owo-java:VERSION'
}
Or you can build the jar yourself (see below)
To get started, create an OwO
object using the Builder class.
REQUIRED
TOKEN
should be replaced with your own unique OwO API key
(OPTIONAL)
You can setendpoint
to use a custom endpoint, default endpoint ishttps://api.awau.moe/
(OPTIONAL)
You can setuploadUrl
to use a custom upload url, default upload URL ishttps://owo.whats-th.is/
(OPTIONAL)
You can setshortenUrl
to use a custom shorten url, default upload URL ishttps://awau.moe/
OwO owo = new OwO.Builder()
.setKey("TOKEN")
.setUploadUrl("https://owo.whats-th.is/")
.setShortenUrl("https://thats-a.link/")
.build();
Next, we can use our newly created owo
object to upload files and shorten urls
OwO#upload
andOwO#shorten
both returnOwoAction
s, these can be executed async using theexecute
method, but can also be executed sync using theexecuteSync
method
owo.shorten("http://my_domain.com").execute(url -> System.out.println("Shortened link: " + url));
owo.upload(new File("my_image.png")).execute(file -> System.out.println("Image URL: " + file.getUrl()));
This code can throw an exception when something goes wrong, to handle this
exception we can add an extra throwable
argument to the execute
method
owo.shorten("http://my_domain.com").execute(url -> System.out.println("Shortened link: " + url), throwable -> /* handle error */);
owo.upload(new File("my_image.png")).execute(file -> System.out.println("Image URL: " + file.getUrl()), throwable -> /* handle error */);
- Run
gradlew shadowJar
in project's root. - The file is located in
build/lib
.
- Run
gradlew build
in project's root. - The file is located in
build/lib
.
Pull requests are accepted, but please make sure your code actually works.
The contents of this repository are licensed under the MIT license. A copy of the MIT license can be found in LICENSE.