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
 PaginatedCollection<Media> getFeed()
          Gets the recent media in the current user's feed
 PaginatedCollection<User> getFollowers(int userId)
           
 java.util.List<User> getFollowRequests()
           
 PaginatedCollection<User> getFollows(int userId)
          Gets a list of users that the user, whose id is passed, follows.
 PaginatedCollection<Media> getLikedMedia()
          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.
 PaginatedCollection<Media> getRecentMediaForTag(java.lang.String tagName)
           
 PaginatedCollection<Media> getRecentMediaFromLocation(int locationId)
           
 PaginatedCollection<Media> getRecentPublishedMedia(int userId)
          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)
           
 DeleteMethod makeDeleteMethod()
           
 GetMethod makeGetMethod()
           
 PostMethod makePostMethod()
           
 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)
           
 void removeHttpProxy()
          Removes the HTTP proxy config
 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.
 void setHttpProxy(java.lang.String address, int port)
          Sets an HTTP proxy for api requests
 
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

setHttpProxy

public void setHttpProxy(java.lang.String address,
                         int port)
Sets an HTTP proxy for api requests

Parameters:
address - ip address of the proxy
port - port number of the proxy

removeHttpProxy

public void removeHttpProxy()
Removes the HTTP proxy config


makeGetMethod

public GetMethod makeGetMethod()

makePostMethod

public PostMethod makePostMethod()

makeDeleteMethod

public DeleteMethod makeDeleteMethod()

getUserById

public User getUserById(int userId)
                 throws java.lang.Exception
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:
java.lang.Exception

getRecentPublishedMedia

public PaginatedCollection<Media> getRecentPublishedMedia(int userId)
                                                   throws java.lang.Exception
Finds and returns the most recent media published by the user with the id passed.

Parameters:
userId - id of the user
Returns:
List of recent media published by the user, within the page number passed
Throws:
Exception, - JSONException
java.lang.Exception

getFeed

public PaginatedCollection<Media> getFeed()
                                   throws java.lang.Exception
Gets the recent media in the current user's feed

Returns:
List of recent media in the current user's feed
Throws:
Exception, - JSONException
java.lang.Exception

getLikedMedia

public PaginatedCollection<Media> getLikedMedia()
                                         throws java.lang.Exception
Gets the recent media that the current user has liked.

Returns:
List of recent media that the current user has liked
Throws:
Exception, - JSONException
java.lang.Exception

getMedia

public Media getMedia(java.lang.String mediaId)
               throws java.lang.Exception
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:
Exception, - JSONException
java.lang.Exception

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 java.lang.Exception
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:
Exception, - JSONException
java.lang.Exception

getPopularMedia

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

Returns:
List of the most popular media on instagram.
Throws:
Exception, - JSONException
java.lang.Exception

searchUsersByName

public java.util.List<User> searchUsersByName(java.lang.String name)
                                       throws java.lang.Exception
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:
Exception, - JSONException
java.lang.Exception

getFollows

public PaginatedCollection<User> getFollows(int userId)
                                     throws java.lang.Exception
Gets a list of users that the user, whose id is passed, follows.

Parameters:
userId - id of the user whose follow list is to be returned
Returns:
List of users by page, that the user, whose id is passed, follows.
Throws:
Exception, - JSONException
java.lang.Exception

getFollowers

public PaginatedCollection<User> getFollowers(int userId)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

getFollowRequests

public java.util.List<User> getFollowRequests()
                                       throws java.lang.Exception,
                                              JSONException,
                                              JSONException
Throws:
java.lang.Exception
JSONException

getRelationshipWith

public Relationship getRelationshipWith(int userId)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

modifyRelationship

public boolean modifyRelationship(int userId,
                                  Relationship.Action action)
                           throws java.lang.Exception
Throws:
java.lang.Exception

postComment

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

removeComment

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

likeMedia

public boolean likeMedia(java.lang.String mediaId)
                  throws java.lang.Exception,
                         JSONException
Throws:
java.lang.Exception
JSONException

removeMediaLike

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

getTag

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

getRecentMediaForTag

public PaginatedCollection<Media> getRecentMediaForTag(java.lang.String tagName)
                                                throws java.lang.Exception
Throws:
java.lang.Exception

searchTags

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

getLocation

public Location getLocation(int locationId)
                     throws java.lang.Exception
Throws:
java.lang.Exception

getRecentMediaFromLocation

public PaginatedCollection<Media> getRecentMediaFromLocation(int locationId)
                                                      throws java.lang.Exception
Throws:
java.lang.Exception