-
Notifications
You must be signed in to change notification settings - Fork 167
jInstagram Usage
Instagram instagram = new Instagram(accessToken);
##Instagram API Endpoints
###Users
-
Get basic information about a user.
UserInfo userInfo = instagram.getUserInfo(1574083); UserInfoData userData = userInfo.getData(); System.out.println("id : " + userData.getId()); System.out.println("first_name : " + userData.getFirst_name()); System.out.println("last_name : " + userData.getLast_name()); System.out.println("profile_picture : " + userData.getProfile_picture()); System.out.println("website : " + userData.getWebsite());
-
See the authenticated user's feed.
MediaFeed mediaFeed = instagram.getUserFeeds(); List<MediaFeedData> mediaFeeds = mediaFeed.getData(); for (MediaFeedData mediaData : mediaFeeds) { System.out.println("id : " + mediaData.getId()); System.out.println("created time : " + mediaData.getCreatedTime()); System.out.println("link : " + mediaData.getLink()); System.out.println("tags : " + mediaData.getTags().toString()); System.out.println("filter : " + mediaData.getImageFilter()); System.out.println("type : " + mediaData.getType()); System.out.println("-- Comments --"); Comments comments = mediaData.getComments(); System.out.println("-- Caption --"); Caption caption = mediaData.getCaption(); System.out.println("-- Likes --"); Likes likes = mediaData.getLikes(); System.out.println("-- Images --"); Images images = mediaData.getImages(); ImageData lowResolutionImg = images.getLowResolution(); ImageData highResolutionImg = images.getHighResolution(); ImageData thumbnailImg = images.getThumbnail(); Location location = mediaData.getLocation(); System.out.println(); }
-
Get the most recent media published by a user. long userId = 3; MediaFeed mediaFeed = instagram.getRecentMediaFeed(userId);
-
See the authenticated user's list of media they've liked.
-
Search for a user by name. String query = "jack"; UserFeed userFeed = instagram.searchUser(query);
List<UserFeedData> userList = userFeed.getUserList(); for(UserFeedData user : userList) { System.out.println("id : " + user.getId()); System.out.println("first_name : " + user.getFirstName()); System.out.println("last_name : " + user.getLastName()); System.out.println("profile_picture : " + user.getProfilePictureUrl()); System.out.println("username : " + user.getUserName()); System.out.println(); }
###Relationship
-
Get the list of users this user follows.
-
Get the list of users this user is followed by.
-
List the users who have requested this user's permission to follow
-
Get information about the current user's relationship (follow/following/etc) to another user.
-
Modify the relationship between the current user and the target user
###Media
-
Get information about a media object.
-
Search for media in a given area.
-
Get a list of what media is most popular at the moment.
###Comments
-
Get a full list of comments on a media.
-
Create a comment on a media.
-
Remove a comment either on the authenticated user's media or authored by the authenticated user.
###Likes
-
Get a list of users who have liked this media.
-
Set a like on this media by the currently authenticated user.
-
Remove a like on this media by the currently authenticated user.
###Tag
-
Get information about a tag object.
-
Get a list of recently tagged media.
-
Search for tags by name - results are ordered first as an exact match, then by popularity.
###Location
-
Get information about a location.
-
Get a list of recent media objects from a given location.
-
Search for a location by geographic coordinate.
##Common Data Elements
-
Meta
Meta meta = mediaFeed.getMeta(); System.out.println("code : " + meta.getCode()); System.out.println("error message : " + meta.getErrorMessage()); System.out.println("error type : " + meta.getErrorType());
-
Pagination
-
User
-
Caption
Caption caption = mediaData.getCaption(); System.out.println("id : " + caption.getId()); System.out.println("created time : " + caption.getCreatedTime()); System.out.println("text : " + caption.getText()); System.out.println("** From **"); System.out.println("id : " + caption.getFrom().getId()); System.out.println("full name : " + caption.getFrom().getFullName()); System.out.println("user name : " + caption.getFrom().getUsername()); System.out.println("profile picture : " + caption.getFrom().getProfilePicture());
-
Comments
Comments comments = mediaData.getComments(); List<CommentData> commentList = comments.getComments(); for (CommentData comment : commentList) { System.out.println("commentId : " + comment.getId()); System.out.println("created Time : " + comment.getCreatedTime()); System.out.println("text : " + comment.getText()); System.out.println("** From **"); System.out.println("id : " + comment.getCommentFrom().getId()); System.out.println("full name : " + comment.getCommentFrom().getFullName()); System.out.println("user name : " + comment.getCommentFrom().getUsername()); System.out.println("profile picture : " + comment.getCommentFrom().getProfilePicture());
-
Location Location location = mediaData.getLocation();
System.out.println("id : " + location.getId()); System.out.println("name : " + location.getName()); System.out.println("latitude : " + location.getLatitude()); System.out.println("longitude : " + location.getLongitude());
-
ImageData
ImageData lowResolutionImg = images.getLowResolution(); System.out.println("url : " + lowResolutionImg.getImageUrl()); System.out.println("width : " + lowResolutionImg.getImageWidth()); System.out.println("height : " + lowResolutionImg.getImageHeight());
-
Likes