Moved from Gradle to bld
This commit is contained in:
parent
886ed86479
commit
f8cf0fd338
321 changed files with 12452 additions and 1492 deletions
23
examples/gradle/src/main/kotlin/com/example/BitlyExample.kt
Normal file
23
examples/gradle/src/main/kotlin/com/example/BitlyExample.kt
Normal file
|
@ -0,0 +1,23 @@
|
|||
package com.example
|
||||
|
||||
import net.thauvin.erik.bitly.Bitly
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (args.isNotEmpty()) {
|
||||
val bitly = Bitly(/* "YOUR_API_ACCESS_TOKEN from https://bitly.is/accesstoken" */)
|
||||
if (bitly.accessToken.isNotEmpty()) {
|
||||
args.forEach {
|
||||
if (it.contains("bit.ly"))
|
||||
println(it + " <-- " + bitly.bitlinks().expand(it))
|
||||
else
|
||||
println(it + " --> " + bitly.bitlinks().shorten(it))
|
||||
}
|
||||
} else {
|
||||
println("Please specify a Bitly API access token.")
|
||||
}
|
||||
} else {
|
||||
println("Try specifying one or more URLs as arguments.")
|
||||
}
|
||||
exitProcess(0)
|
||||
}
|
25
examples/gradle/src/main/kotlin/com/example/BitlyRetrieve.kt
Normal file
25
examples/gradle/src/main/kotlin/com/example/BitlyRetrieve.kt
Normal file
|
@ -0,0 +1,25 @@
|
|||
package com.example
|
||||
|
||||
import net.thauvin.erik.bitly.Bitly
|
||||
import net.thauvin.erik.bitly.Methods
|
||||
import net.thauvin.erik.bitly.Utils.toEndPoint
|
||||
import org.json.JSONObject
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
fun main() {
|
||||
val bitly = Bitly(/* "YOUR_API_ACCESS_TOKEN from https://bitly.is/accesstoken" */)
|
||||
|
||||
// See https://dev.bitly.com/v4/#operation/getBitlink
|
||||
val response = bitly.call("/bitlinks/bit.ly/380ojFd", method = Methods.GET)
|
||||
|
||||
if (response.isSuccessful) {
|
||||
val json = JSONObject(response.body)
|
||||
println("Title : " + json.getString("title"))
|
||||
println("URL : " + json.getString("long_url"))
|
||||
println("By : " + json.getString("created_by"))
|
||||
} else {
|
||||
println("${response.message}: ${response.description} (${response.statusCode})")
|
||||
}
|
||||
|
||||
exitProcess(0)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue