KKBOX-XDDD/KKBOXOpenApi-Android


Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.kkbox-xddd:kkboxopenapi-android:1.2.3'
	}
	dependencies {
		implementation("com.github.kkbox-xddd:kkboxopenapi-android:1.2.3")
	}
	<dependency>
	    <groupId>com.github.kkbox-xddd</groupId>
	    <artifactId>kkboxopenapi-android</artifactId>
	    <version>1.2.3</version>
	</dependency>

                            
    libraryDependencies += "com.github.kkbox-xddd" % "kkboxopenapi-android" % "1.2.3"
        
        

                            
    :dependencies [[com.github.kkbox-xddd/kkboxopenapi-android "1.2.3"]]
        
        

Readme


KKBOXOpenApi-Android

KKBOXOpenApi-Android

The library helps to access KKBOX's Open API.

Installation

1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.KKBOX-XDDD:KKBOXOpenApi-Android:${last_jitpack_version}'
}

Usage

To start using a library, you need a valid client ID and secret. You can get one from KKBOX's developer site.

Then, you need to fetch a valid access token.

KKBOXOpenApi.install(
        "fc87971f683fd619ba46be6e3aa2cbc2",
        "5b70cd567551d03d4c43c5cec9e02d1a",
        OkhttpRequestExecutor(OkHttpClient())
)
KKBOXOpenApi.update(Java8Crypto())
KKBOXOpenApi.fetchAuthToken({ throw AssertionError("Fetch token fail.") }) {
    /// Handle the success case.
}

Once you have an access token, you can create instance of the classes for various APIs. For example:

AlbumApi("KmRKnW5qmUrTnGRuxF").start(this, { throw AssertionError("testRequest_success fail") }) {
    assert(it.name.isNotEmpty()) {
        "album name not be empty."
    }
}