-
Notifications
You must be signed in to change notification settings - Fork 5
JxInsta
This page is all about the main JxInsta
class and its methods.
You can either log in using your username-password or with cookies/bearer token.
This will always create a new login session (which means that it will attempt to log in every time the code runs)
JxInsta instagram = new JxInsta("username","password",loginType);
Here, login type is one of, JxInsta.LoginType.WEB_AUTHENTICATION, LoginType.APP_AUTHENTICATION, LoginType.BOTH_APP_WEB_AUTHENTICATION.
You would not like to log in every time users run your program. After login, you can cache that Instagram instance and can use it every time you create an Instagram object. See this example:
JxInsta insta = new JxInsta("cookie","bearer token");
This method will use the cookie or token for the authentication. This library will primarily use cookies for authorization, the token will only be used in the endpoint that does not work with cookies (strictly mobile).
Just use it like you use any object of the class to get or set data. It's very much similar and simple.
JxInsta insta = new JxInsta("cookie", "bearer token");
List<Post> posts = insta.getFeedPosts(10, null);
List<Story[]> stories = insta.getFeedStories();
Profile profile = insta.getProfile("x0.rahil");
insta.uploadStory(new File("path/to/photo"));
insta.postPicture(new FileInputStream(new File("path/to/photo")),"caption", false);
To see about the return classes, please check out the respective page of the documentation.
You have successfully learned to use Instagram programmatically. Now it's time to build amazing apps or bots using this library.