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