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.captainjackbard:instagram4j:instagram4j-1.1'
}
dependencies {
implementation("com.github.captainjackbard:instagram4j:instagram4j-1.1")
}
<dependency>
<groupId>com.github.captainjackbard</groupId>
<artifactId>instagram4j</artifactId>
<version>instagram4j-1.1</version>
</dependency>
libraryDependencies += "com.github.captainjackbard" % "instagram4j" % "instagram4j-1.1"
:dependencies [[com.github.captainjackbard/instagram4j "instagram4j-1.1"]]
:camera: Java client to Instagram's private API. Allows access to all the features that Instagram app provides.
Based on the Instagram PHP Api and Instagram Python Api.
Download the latest release JAR or grab via Maven:
<dependency>
<groupId>org.brunocvcunha.instagram4j</groupId>
<artifactId>instagram4j</artifactId>
<version>1.1</version>
</dependency>
or Gradle:
compile 'org.brunocvcunha.instagram4j:instagram4j:1.1'
// Login to instagram
Instagram4j instagram = Instagram4j.builder().username("username").password("password").build();
instagram.setup();
instagram.login();
InstagramSearchUsernameResult userResult = instagram.sendRequest(new InstagramSearchUsernameRequest("github"));
System.out.println("ID for @github is " + userResult.getUser().getPk());
System.out.println("Number of followers: " + userResult.getUser().getFollower_count());
instagram.sendRequest(new InstagramFollowRequest(userResult.getUser().getPk()));
instagram.sendRequest(new InstagramUnfollowRequest(userResult.getUser().getPk()));
InstagramGetUserFollowersResult githubFollowers = instagram.sendRequest(new InstagramGetUserFollowersRequest(userResult.getUser().getPk()));
List<InstagramUserSummary> users = githubFollowers.getUsers();
for (InstagramUserSummary user : users) {
System.out.println("User " + user.getUsername() + " follows Github!");
}
InstagramSearchUsernameResult userResult = instagram.sendRequest(new InstagramSearchUsernameRequest("github"));
System.out.println("ID for @github is " + userResult.getUser().getPk());
System.out.println("Number of followers: " + userResult.getUser().follower_count);
instagram.sendRequest(new InstagramUploadPhotoRequest(
new File("/tmp/file-to-upload.jpg"),
"Posted with Instagram4j, how cool is that?"));
instagram.sendRequest(new InstagramUploadVideoRequest(
new File("/tmp/file-to-upload.mp4"),
"Video posted with Instagram4j, how cool is that?"));
InstagramFeedResult tagFeed = instagram.sendRequest(new InstagramTagFeedRequest("github"));
for (InstagramFeedItem feedResult : tagFeed.getItems()) {
System.out.println("Post ID: " + feedResult.getPk());
}
instagram.sendRequest(new InstagramLikeRequest(feedResult.getPk()));
git clone https://github.com/brunocvcunha/instagram4j
cd instagram4j
mvn clean install
Snapshots of the development version are available in Sonatype's snapshots
repository.
instagram4j requires at minimum Java 8.