Cleaned up and added retrieve example.

This commit is contained in:
Erik C. Thauvin 2020-03-01 20:41:33 -08:00
parent b7066f6ff7
commit b31b21d481
3 changed files with 21 additions and 1 deletions

View file

@ -15,6 +15,7 @@ repositories {
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.json:json:20190722")
implementation("net.thauvin.erik:bitly-shorten:0.9.0-beta")
}

View file

@ -5,7 +5,7 @@ import kotlin.system.exitProcess
fun main(args: Array<String>) {
if (args.isNotEmpty()) {
val bitly = Bitly(/* "YOUR_API_ACCESS_TOKEN from https://bitly.is/accesstoken" */) //
val bitly = Bitly(/* "YOUR_API_ACCESS_TOKEN from https://bitly.is/accesstoken" */)
args.forEach {
if (it.contains("bit.ly"))
println(it + " <-- " + bitly.bitlinks().expand(it))

View file

@ -0,0 +1,19 @@
package com.example
import net.thauvin.erik.bitly.Bitly
import net.thauvin.erik.bitly.Methods
import net.thauvin.erik.bitly.Utils.Companion.toEndPoint
import org.json.JSONObject
import kotlin.system.exitProcess
fun main() {
val bitly = Bitly(/* "YOUR_API_ACCESS_TOKEN from https://bitly.is/accesstoken" */)
val json = JSONObject(bitly.call("/bitlinks/bit.ly/380ojFd".toEndPoint(), method = Methods.GET))
println("Bitlink is titled : " + json.getString("title"))
println("Bitlink created by: " + json.getString("created_by"))
exitProcess(0)
}