Instagram4Android


Source link: https://github.com/charlieAndroidDev/Instagram4Android

Instagram4Android

This library directly talks to the private Instagram API, anything (well quite a lot) you can do on the IG app you can replicate with this library. You also bypass the public API's rate limits.

Credit

This was originally a port of a popular Java repository that provides access to Instagrams' private API. This has been changed around to use OkHttp and various other fixes have been made to make it work with Android. I will be updating this with more endpoints and so on as time goes on.

Project not in any way afilliated with Instagram.

Fair Use

Do NOT use this to spam anyone at all.
Do NOT use this for any illegal activities.

Installation

Add the following to your root build.gradle file:

allprojects {

  repositories {
  ...  maven {
 url 'https://jitpack.io' 
}

  
}
 
}

Then add the following to your app level build.gradle file, use the version number of the latest release:

dependencies {
     compile 'com.github.charlieAndroidDev:Instagram4Android:$VERSION' 
}

Instructions

Login

Instagram4Android instagram = Instagram4Android.builder().username(username).password(password).build();
 instagram.setup();
 instagram.login();

You must call setup() before login() otherwise an exception is thrown.

Below is my implementation of logging in to Instagram in my presenter (MVP) using RxJava2 and RxAndroid:

private void loginToInstagram(final String username, final String password) {

 Instagram4Android instagram = Instagram4Android.builder().username(username).password(password).build();

 attemptLogin(instagram, username, password)                 .subscribeOn(Schedulers.io())                 .observeOn(AndroidSchedulers.mainThread())

  .subscribe(instagramLoginResult -> {

 if(instagramLoginResult.getStatus().equals(view.getStringResource(R.string.login_success))) {

 view.loginFinished(instagram);

}
 else {

 view.loginFailed(instagramLoginResult.getMessage());

}

}
);

}
  private Observable<InstagramLoginResult> attemptLogin(final Instagram4Android instagram) {

 Observable<InstagramLoginResult> observable = Observable.create(observableEmitter -> {

  instagram.setup();

 observableEmitter.onNext(instagram.login());

 
}
);

 return observable;

}

 

The String resource R.string.login_success is "ok".

Get user info

InstagramSearchUsernameResult result = instagram.sendRequest(new InstagramSearchUsernameRequest("example_username"));
 InstagramUser user = result.getUser();

Send the request using your Instagram4Android instance, and then call getUser() on the result. Now poke around and see what info you can get from that user object.

Follow user

instagram.sendRequest(new InstagramFollowRequest(user.getPk()));

Very simple.

Get stories (the ones you see at the top of your homepage)

InstagramReelsTrayFeedResult result = instagram4Android.sendRequest(new InstagramReelsTrayRequest());
 List<InstagramStoryTray> trays = result.getTray();

trays now contains a list of InstagramStoryTray which, for the first few elements, will have a list of story items and info about the user whose story it is. After the first 3-5 elements the list of story items will be null (We'll fix that below).

To get the rest of the story items for everyone in your reel tray do this:

InstagramReelsTrayFeedResult result = instagram4Android.sendRequest(new InstagramReelsTrayRequest());
 List<InstagramStoryTray> trays = result.getTray();
  List<InstagramUserStoryFeedResult> userStories = new ArrayList<>();
 for(InstagramStoryTray tray : trays) {

  if(tray != null) {

userStories.add(instagram4Android.sendRequest(new InstagramUserStoryFeedRequest("" + tray.getUser().getPk())));

  
}
 
}
  // To print the url's of the first items in everyones story do this for(InstagramUserStoryFeedResult story : userStories) {

  if(story.getReel() == null) {

System.out.println("Null check for safety, hardly ever null");

  
}
 else {

System.out.println(story.getReel().getItems().get(0).getImage_versions2().getCandidates().get(0).getUrl());

  
}
 
}

Resources

A Simple Audio Recorder View with hold to record button and swipe to cancel.

Changing colors of drawable icons by reusing the single icon with different colors.

A library that manages state using RxJava 2.

CurrencyPicker is a simple library that can be show a currency picker.

Android-CustomToast is a powerful & easy to use Custom Toast library for Android. It runs on API level 14 and upwards.

This library provides some predefined custom toast. Also you can coustomize the toast according to your need

A Single line of code can add a beautiful toast message in your app.

Simple Dribbble client for android.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes