2
我正在構建一個需要關於一本書的用戶評論的android應用程序。在谷歌搜索後,我發現Goodreads API可以很好的爲此目的。但問題是,沒有明確的文件爲Java或Android。使用Goodreads API for android
我該如何使用Goodreads API爲我的應用程序?任何代碼示例都可以很好地解釋。
我正在構建一個需要關於一本書的用戶評論的android應用程序。在谷歌搜索後,我發現Goodreads API可以很好的爲此目的。但問題是,沒有明確的文件爲Java或Android。使用Goodreads API for android
我該如何使用Goodreads API爲我的應用程序?任何代碼示例都可以很好地解釋。
好傢伙,
take the referral code form
[MarcBernstein/Android的goodreads-API] https://github.com/MarcBernstein/android-goodreads-api
此做如下代碼的變化,如果它不與你的Android工作室compaitable後。
在build.gradle-
buildscript
{
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.9.+'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/maven/commons-io/commons-io/pom.xml'
exclude 'META-INF/maven/commons-io/commons-io/pom.properties'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), ' proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libraries:android-goodreads-api')
compile 'com.squareup.picasso:picasso:2.+'
compile 'com.squareup:otto:1.3.4'
compile 'com.squareup.retrofit:retrofit:1.5.0'
compile ('com.squareup.retrofit:converter-simplexml:1.5.0') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'org.json:json:20140107'
compile 'org.apache.commons:commons-io:+'
compile 'org.apache.commons:commons-lang3:+'
compile 'com.google.guava:guava:16.+'
compile 'com.google.code.gson:gson:+'
compile 'oauth.signpost:signpost-core:+'
compile 'oauth.signpost:signpost-commonshttp4:+'
compile ('org.simpleframework:simple-xml:+') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
}
在goodsreads阿比搖籃文件此更改後---
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.squareup.picasso:picasso:2.+'
compile 'com.squareup:otto:1.3.4'
compile 'com.squareup.retrofit:retrofit:1.5.0'
compile ('com.squareup.retrofit:converter-simplexml:1.5.0') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'org.json:json:20140107'
compile 'org.apache.commons:commons-io:+'
compile 'org.apache.commons:commons-lang3:+'
compile 'com.google.guava:guava:16.+'
compile 'com.google.code.gson:gson:+'
compile 'oauth.signpost:signpost-core:+'
compile 'oauth.signpost:signpost-commonshttp4:+'
compile ('org.simpleframework:simple-xml:+') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
}
3.改變搖籃文件的類路徑。
4.配置數據
<string name="oauth_developer_key">your developer key</string>
<string name="oauth_developer_secret">your developer secret</string>
<string name="oauth_callback_url">com.goodreads://oauth_callback</string>
5.在庫模塊的
私有靜態最後字符串API_URL = 「https://www.goodreads.com/」 GoodreadsAPI文件更改;
private static final String AUTHORIZATION_WEBSITE_URL = "http://www.goodreads.com/oauth/authorize?mobile=1";
private static final String ACCESS_TOKEN_ENDPOINT_URL = "http://www.goodreads.com/oauth/access_token";
private static final String REQUEST_TOKEN_ENDPOINT_URL = "http://www.goodreads.com/oauth/request_token";
[First hit](https://github.com/rharter/goodreads-api)搜索「goodreads java api」時。 – Michael
@Michael我該如何在我的應用中使用它? –
https://www.goodreads.com/api第一個鏈接出現時,你谷歌「goodreads Java API」,它的安靜清晰本身。 – Avijeet