Added check for valid API token.
This commit is contained in:
parent
2485f898de
commit
e2cb9e2954
7 changed files with 25 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("org.jetbrains.kotlin.jvm") version "1.3.71"
|
id("org.jetbrains.kotlin.jvm") version "1.3.72"
|
||||||
id("com.github.ben-manes.versions") version "0.28.0"
|
id("com.github.ben-manes.versions") version "0.28.0"
|
||||||
application
|
application
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ 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("net.thauvin.erik:bitly-shorten:0.9.1-beta")
|
implementation("net.thauvin.erik:bitly-shorten:0.9.2")
|
||||||
implementation("org.json:json:20190722")
|
implementation("org.json:json:20200518")
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
|
|
BIN
examples/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
examples/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
2
examples/gradlew
vendored
2
examples/gradlew
vendored
|
@ -82,6 +82,7 @@ esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
@ -129,6 +130,7 @@ fi
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
|
1
examples/gradlew.bat
vendored
1
examples/gradlew.bat
vendored
|
@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,16 @@ public final class BitlySample {
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
final Bitly bitly = new Bitly(/* "YOUR_API_TOKEN from https://bitly.is/accesstoken" */);
|
final Bitly bitly = new Bitly(/* "YOUR_API_TOKEN from https://bitly.is/accesstoken" */);
|
||||||
for (final String arg : args) {
|
if (!bitly.getAccessToken().isEmpty()) {
|
||||||
if (arg.contains("bit.ly")) {
|
for (final String arg : args) {
|
||||||
System.out.println(arg + " <-- " + bitly.bitlinks().expand(arg));
|
if (arg.contains("bit.ly")) {
|
||||||
} else {
|
System.out.println(arg + " <-- " + bitly.bitlinks().expand(arg));
|
||||||
System.out.println(arg + " --> " + bitly.bitlinks().shorten(arg));
|
} else {
|
||||||
|
System.out.println(arg + " --> " + bitly.bitlinks().shorten(arg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
System.err.println("Please specify a Bitly API access token.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.err.println("Try specifying one or more URLs as arguments.");
|
System.err.println("Try specifying one or more URLs as arguments.");
|
||||||
|
|
|
@ -6,11 +6,15 @@ 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 {
|
if (bitly.accessToken.isNotEmpty()) {
|
||||||
if (it.contains("bit.ly"))
|
args.forEach {
|
||||||
println(it + " <-- " + bitly.bitlinks().expand(it))
|
if (it.contains("bit.ly"))
|
||||||
else
|
println(it + " <-- " + bitly.bitlinks().expand(it))
|
||||||
println(it + " --> " + bitly.bitlinks().shorten(it))
|
else
|
||||||
|
println(it + " --> " + bitly.bitlinks().shorten(it))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println("Please specify a Bitly API access token.")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println("Try specifying one or more URLs as arguments.")
|
println("Try specifying one or more URLs as arguments.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue