gpt4 book ai didi

android - 使用适用于 Android 的 Goodreads API

转载 作者:搜寻专家 更新时间:2023-11-01 07:51:25 28 4
gpt4 key购买 nike

我正在构建一个 Android 应用程序,它需要用户对一本书进行评论。在谷歌搜索后,我发现 Goodreads API可以很好地用于此目的。但问题是没有明确的 java 或 android 文档。

如何为我的应用程序使用 Goodreads API?任何代码示例都可以很好地解释。

最佳答案

大家好,

               take the referral code form

[MarcBernstein/android-goodreads-api] https://github.com/MarcBernstein/android-goodreads-api

在此之后,如果它与您的 android studio 不兼容,请对代码进行以下更改。

在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 Api Gradle 文件中的这个变化之后---

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。更改 Gradle 文件的类路径。

<强>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。库模块的 GoodreadsAPI 文件发生变化

private static final String API_URL = "https://www.goodreads.com/ ";

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";

关于android - 使用适用于 Android 的 Goodreads API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34526630/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com