is.gd Shortener for Kotlin, Java & Android https://github.com/ethauvin/isgd-shorten
Find a file
2021-08-25 09:22:39 -07:00
.circleci Upgrade to JDK 16, Kotlin 1.3.21 and Gradle 7.1.1 2021-07-27 15:15:46 -07:00
.github/workflows Upgrade to JDK 16, Kotlin 1.3.21 and Gradle 7.1.1 2021-07-27 15:15:46 -07:00
.idea Dependencies updates. Kotlin 1.5.30. 2021-08-25 09:22:39 -07:00
config/detekt Implemented IsgdException. Closes #1 2021-06-05 13:53:42 -07:00
examples Dependencies updates. Kotlin 1.5.30. 2021-08-25 09:22:39 -07:00
gradle/wrapper Dependencies updates. Kotlin 1.5.30. 2021-08-25 09:22:39 -07:00
src Upgrade to JDK 16, Kotlin 1.3.21 and Gradle 7.1.1 2021-07-27 15:15:46 -07:00
.editorconfig Initial commit. 2020-03-21 19:35:34 -07:00
.gitattributes Initial commit. 2020-03-21 19:35:34 -07:00
.gitignore Upgrade to JDK 16, Kotlin 1.3.21 and Gradle 7.1.1 2021-07-27 15:15:46 -07:00
.gitlab-ci.yml Using system wide Gradle. 2021-05-21 13:09:35 -07:00
bitbucket-pipelines.yml Upgraded to the Gradle 6.6 and Kotlin 1.4.0. 2020-08-17 23:57:23 -07:00
build.gradle.kts Dependencies updates. Kotlin 1.5.30. 2021-08-25 09:22:39 -07:00
gradlew Dependencies updates. Kotlin 1.5.30. 2021-08-25 09:22:39 -07:00
gradlew.bat Upgraded to the Gradle 6.6 and Kotlin 1.4.0. 2020-08-17 23:57:23 -07:00
LICENSE.txt Upgraded to Kotlin 1.5.0 2021-04-28 10:50:10 -07:00
pom.xml Dependencies updates. Kotlin 1.5.30. 2021-08-25 09:22:39 -07:00
README.md Implemented IsgdException. Closes #1 2021-06-05 13:53:42 -07:00
settings.gradle.kts Upgrade to JDK 16, Kotlin 1.3.21 and Gradle 7.1.1 2021-07-27 15:15:46 -07:00
version.properties Added support for snapshot. 2021-05-02 22:18:43 -07:00

License (3-Clause BSD) release Maven Central

Known Vulnerabilities Quality Gate Status GitHub CI CircleCI

is.gd Shortener for Kotlin/Java/Android

A simple implementation of the is.gd API.

Examples (TL;DR)

import net.thauvin.erik.isgd.Isgd

...

Isgd.shorten("https://www.example.com/") // returns https://is.gd/Pt2sET
Isgd.lookup("https://is.gd/Pt2sET") // returns https://www.example.com

JSON or XML

The is.gd API can return data in plain text (default), JSON or XML.

Isgd.shorten("https://www.example.com/", format = Format.JSON)

returns:

{ "shorturl": "https://is.gd/Pt2sET" }

Parameters

All of the is.gd API parameters are supported:

Isgd.shorten(url = url, shorturl="foobar", callback = "test", logstats = true, format = Format.JSON)

returns:

test({ "shorturl": "https://is.gd/foobar" });

Gradle

To use with Gradle, include the following dependency in your build file:

dependencies {
    implementation("net.thauvin.erik:isgd-shorten:0.9.2")
}

Instructions for using with Maven, Ivy, etc. can be found on Maven Central.

Errors

An IsgdException is thrown when an API error occurs. The error message (text, XML or JSON) and HTTP status code can be retrieved as follows:

try {
    Isgd.shorten("http://is.gd/Pt2sET") // already shorten
} catch (e: IsgdException)
    println("Status Code: ${e.statusCode}")
    println("${e.message})
}
Status Code: 400
Error: Sorry, the URL you entered is on our internal blacklist. It may have been used abusively in the past, or it may link to another URL redirection service.

v.gd

Additionally, link can be shortened using v.gd by setting the isVgd flag:

Isgd.shorten("https://www.example.com/", isVgd = true) // returns https://v.gd/2z2ncj