com.sola.instagram
Class InstagramSession

java.lang.Object
  extended by com.sola.instagram.InstagramSession

public class InstagramSession
extends java.lang.Object

Constains a methods used to interact with the API.

Version:
2012-08-22
Author:
Sola Ogunsakin

Constructor Summary
InstagramSession()
           
InstagramSession(AccessToken accessToken)
          Creates a new Instagram session
 
Method Summary
 java.util.ArrayList<Media> getFeed(int pageNumber)
          Gets the recent media in the current user's feed.
 java.util.List<User> getFollowers(int userId, int pageNumber)
           
 java.util.List<User> getFollowRequests()
           
 java.util.List<User> getFollows(int userId, int pageNumber)
          Gets a list of users that the user, whose id is passed, follows.
 java.util.List<Media> getLikedMedia(int pageNumber)
          Gets the recent media that the current user has liked.
 Location getLocation(int locationId)
           
 Media getMedia(java.lang.String mediaId)
          Gets the media with the id passed.
 java.util.List<Media> getPopularMedia()
          Finds and returns the most popular media on instagram.
 java.util.List<Media> getRecentMediaForTag(java.lang.String tagName, int pageNumber)
           
 java.util.List<Media> getRecentMediaFromLocation(int locationId, int pageNumber)
           
 java.util.List<Media> getRecentPublishedMedia(int userId, int pageNumber)
          Finds and returns the most recent media published by the user with the id passed.
 Relationship getRelationshipWith(int userId)
           
 Tag getTag(java.lang.String tagName)
           
 User getUserById(int userId)
          Finds and returns a user with the given id.
 boolean likeMedia(java.lang.String mediaId)
           
 boolean modifyRelationship(int userId, Relationship.Action action)
           
 Comment postComment(java.lang.String mediaId, java.lang.String text)
           
 boolean removeComment(java.lang.String mediaId, java.lang.String commentId)
           
 boolean removeMediaLike(java.lang.String mediaId)
           
 java.util.List<Media> searchMedia(java.lang.Object latitude, java.lang.Object longitude, java.lang.Object minTimestamp, java.lang.Object maxTimestamp, java.lang.Object distance)
          Searches for media by location and creation time.
 java.util.List<Tag> searchTags(java.lang.String tagName)
           
 java.util.List<User> searchUsersByName(java.lang.String name)
          Searches for users by name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstagramSession

public InstagramSession()

InstagramSession

public InstagramSession(AccessToken accessToken)
Creates a new Instagram session

Parameters:
accessToken - the session's access token
Method Detail

getUserById

public User getUserById(int userId)
                 throws InstagramException
Finds and returns a user with the given id. Throws an InstagramException if none is found or the user with that id cannot be accessed

Parameters:
userId - id of the user
Returns:
The user with the id passed
Throws:
InstagramException

getRecentPublishedMedia

public java.util.List<Media> getRecentPublishedMedia(int userId,
                                                     int pageNumber)
                                              throws InstagramException
Finds and returns the most recent media published by the user with the id passed. Results are paginated, the required page must also be indicated

Parameters:
userId - id of the user
pageNumber - the required result page. Must be > 0.
Returns:
List of recent media published by the user, within the page number passed
Throws:
InstagramException

getFeed

public java.util.ArrayList<Media> getFeed(int pageNumber)
                                   throws InstagramException
Gets the recent media in the current user's feed. Results are paginated, the required page must also be indicated.

Parameters:
pageNumber - the required result page. Must be > 0.
Returns:
List of recent media in the current user's feed
Throws:
InstagramException

getLikedMedia

public java.util.List<Media> getLikedMedia(int pageNumber)
                                    throws InstagramException
Gets the recent media that the current user has liked. Results are paginated, the required page must also be indicated.

Parameters:
pageNumber - the required result page. Must be > 0.
Returns:
List of recent media that the current user has liked
Throws:
InstagramException

getMedia

public Media getMedia(java.lang.String mediaId)
               throws InstagramException
Gets the media with the id passed. Throws an InstagramException if no media with that is is found.

Parameters:
mediaId - the id of the media to be returned
Returns:
The media with the id passed
Throws:
InstagramException

searchMedia

public java.util.List<Media> searchMedia(java.lang.Object latitude,
                                         java.lang.Object longitude,
                                         java.lang.Object minTimestamp,
                                         java.lang.Object maxTimestamp,
                                         java.lang.Object distance)
                                  throws InstagramException
Searches for media by location and creation time.

Parameters:
latitude - latitude of location
longitude - longitude of location
minTimestamp - the min timestamp of media to be returned. Can be null if needed.
maxTimestamp - the max timestamp of media to be returned. Can be null if needed.
distance - the of the location. Can be null if needed.
Returns:
List of recent media that meet the search parameters
Throws:
InstagramException

getPopularMedia

public java.util.List<Media> getPopularMedia()
                                      throws InstagramException
Finds and returns the most popular media on instagram.

Returns:
List of the most popular media on instagram.
Throws:
InstagramException

searchUsersByName

public java.util.List<User> searchUsersByName(java.lang.String name)
                                       throws InstagramException
Searches for users by name.

Parameters:
name - the full name or username of the user to be returned
Returns:
List of users who match the search criteria
Throws:
InstagramException

getFollows

public java.util.List<User> getFollows(int userId,
                                       int pageNumber)
                                throws InstagramException
Gets a list of users that the user, whose id is passed, follows. Results are paginated, the required page must also be indicated

Parameters:
userId - id of the user whose follow list is to be returned
pageNumber - the required result page. Must be > 0.
Returns:
List of users by page, that the user, whose id is passed, follows.
Throws:
InstagramException

getFollowers

public java.util.List<User> getFollowers(int userId,
                                         int pageNumber)
                                  throws InstagramException
Throws:
InstagramException

getFollowRequests

public java.util.List<User> getFollowRequests()
                                       throws InstagramException
Throws:
InstagramException

getRelationshipWith

public Relationship getRelationshipWith(int userId)
                                 throws InstagramException
Throws:
InstagramException

modifyRelationship

public boolean modifyRelationship(int userId,
                                  Relationship.Action action)
                           throws InstagramException
Throws:
InstagramException

postComment

public Comment postComment(java.lang.String mediaId,
                           java.lang.String text)
                    throws InstagramException
Throws:
InstagramException

removeComment

public boolean removeComment(java.lang.String mediaId,
                             java.lang.String commentId)
                      throws InstagramException
Throws:
InstagramException

likeMedia

public boolean likeMedia(java.lang.String mediaId)
                  throws InstagramException
Throws:
InstagramException

removeMediaLike

public boolean removeMediaLike(java.lang.String mediaId)
                        throws InstagramException
Throws:
InstagramException

getTag

public Tag getTag(java.lang.String tagName)
           throws InstagramException
Throws:
InstagramException

getRecentMediaForTag

public java.util.List<Media> getRecentMediaForTag(java.lang.String tagName,
                                                  int pageNumber)
                                           throws InstagramException
Throws:
InstagramException

searchTags

public java.util.List<Tag> searchTags(java.lang.String tagName)
                               throws InstagramException
Throws:
InstagramException

getLocation

public Location getLocation(int locationId)
                     throws InstagramException
Throws:
InstagramException

getRecentMediaFromLocation

public java.util.List<Media> getRecentMediaFromLocation(int locationId,
                                                        int pageNumber)
                                                 throws InstagramException
Throws:
InstagramException