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.uakihir0:mastodon4j:0.3.9'
}
dependencies {
implementation("com.github.uakihir0:mastodon4j:0.3.9")
}
<dependency>
<groupId>com.github.uakihir0</groupId>
<artifactId>mastodon4j</artifactId>
<version>0.3.9</version>
</dependency>
libraryDependencies += "com.github.uakihir0" % "mastodon4j" % "0.3.9"
:dependencies [[com.github.uakihir0/mastodon4j "0.3.9"]]
Java library for the Mastodon API. It's from hecateball/mastodon4j. This can complie with google/j2objc to Objective-C library. (for iOS and Mac OS)
It also supports PixelFed and Pleroma, which are built similarly to the Mastodon API. (However, you need to specify the service at the time of instantiation because some processes are different for each service.)
It is available with jitpack.io.
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.uakihir0:mastodon4j:0.2'
}
Get user object for the authenticated account.
// Make Mastodon instance.
Mastodon mastodon = MastodonFactory.getInstance(
Service.MASTODON,
MastodonHost,
AccessToken
);
// Request
Response<Account> me = mastodon.verifyCredentials();
// Print user's name
System.out.println(me.get().getDisplayName());
to use more functions, please see Mastodon.java.
This software is released under the MIT License, see LICENSE.txt.