Removed toJson() in CallResponse.
This commit is contained in:
parent
353927580d
commit
8060f856ee
9 changed files with 28 additions and 26 deletions
|
@ -4,8 +4,8 @@ import net.thauvin.erik.bitly.Bitly;
|
|||
|
||||
public class BitlySample {
|
||||
public static void main(String[] args) {
|
||||
final Bitly bitly = new Bitly(/* "YOUR_API_TOKEN from https://bitly.is/accesstoken" */);
|
||||
if (args.length > 0) {
|
||||
final Bitly bitly = new Bitly(/* "YOUR_API_TOKEN from https://bitly.is/accesstoken" */);
|
||||
for (final String arg : args) {
|
||||
if (arg.contains("bit.ly")) {
|
||||
System.out.println(arg + " <-- " + bitly.bitlinks().expand(arg));
|
||||
|
|
|
@ -3,16 +3,23 @@ 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 = bitly.call("/bitlinks/bit.ly/380ojFd".toEndPoint(), method = Methods.GET).toJson()
|
||||
// See https://dev.bitly.com/v4/#operation/getBitlink
|
||||
val response = 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"))
|
||||
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("Invalid Response: ${response.resultCode}")
|
||||
}
|
||||
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue