Cleaned up and added retrieve example.
This commit is contained in:
parent
b7066f6ff7
commit
b31b21d481
3 changed files with 21 additions and 1 deletions
|
@ -15,6 +15,7 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
|
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
|
||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
|
implementation("org.json:json:20190722")
|
||||||
|
|
||||||
implementation("net.thauvin.erik:bitly-shorten:0.9.0-beta")
|
implementation("net.thauvin.erik:bitly-shorten:0.9.0-beta")
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import kotlin.system.exitProcess
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
if (args.isNotEmpty()) {
|
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 {
|
args.forEach {
|
||||||
if (it.contains("bit.ly"))
|
if (it.contains("bit.ly"))
|
||||||
println(it + " <-- " + bitly.bitlinks().expand(it))
|
println(it + " <-- " + bitly.bitlinks().expand(it))
|
||||||
|
|
19
examples/src/main/kotlin/com/example/BitlyRetrieve.kt
Normal file
19
examples/src/main/kotlin/com/example/BitlyRetrieve.kt
Normal 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)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue