Beispiel #1
0
  /**
   * Set the relationship between the current user and the target user
   *
   * @param userId userId of the user.
   * @param relationship Relationship status
   * @return a Relationship feed object
   * @throws InstagramException if any error occurs.
   */
  public RelationshipFeed setUserRelationship(String userId, Relationship relationship)
      throws InstagramException {
    Preconditions.checkEmptyString(userId, "userId cannot be null or empty.");
    Preconditions.checkNotNull(relationship, "relationship cannot be null.");

    String apiMethod = String.format(Methods.USERS_ID_RELATIONSHIP, userId);
    Map<String, String> params = new HashMap<String, String>();

    params.put(QueryParam.ACTION, relationship.toString());

    return createInstagramObject(Verbs.POST, RelationshipFeed.class, apiMethod, params);
  }
Beispiel #2
0
  /**
   * Get information about a media object.
   *
   * @param shortcode shortcode of the Media object.
   * @return a mediaFeed object.
   * @throws InstagramException if any error occurs.
   */
  public MediaInfoFeed getMediaInfoByShortcode(String shortcode) throws InstagramException {
    Preconditions.checkNotNull(shortcode, "shortcode cannot be null.");

    String apiMethod = String.format(Methods.MEDIA_BY_SHORTCODE, shortcode);

    return createInstagramObject(Verbs.GET, MediaInfoFeed.class, apiMethod, null);
  }
Beispiel #3
0
  /**
   * Get information about a media object.
   *
   * @param mediaId mediaId of the Media object.
   * @return a mediaFeed object.
   * @throws InstagramException if any error occurs.
   */
  public MediaInfoFeed getMediaInfo(String mediaId) throws InstagramException {
    Preconditions.checkNotNull(mediaId, "mediaId cannot be null.");

    String apiMethod = String.format(Methods.MEDIA_BY_ID, mediaId);

    return createInstagramObject(Verbs.GET, MediaInfoFeed.class, apiMethod, null);
  }
Beispiel #4
0
  /**
   * Get the most recent media published by a user.
   *
   * @param userId
   * @param count
   * @param minId
   * @param maxId
   * @param maxTimeStamp
   * @param minTimeStamp
   * @return the mediaFeed object
   * @throws InstagramException if any error occurs
   */
  public MediaFeed getRecentMediaFeed(
      String userId, int count, String minId, String maxId, Date maxTimeStamp, Date minTimeStamp)
      throws InstagramException {
    Preconditions.checkEmptyString(userId, "UserId cannot be null or empty.");
    Map<String, String> params = new HashMap<String, String>();

    if (maxId != null) {
      params.put(QueryParam.MAX_ID, String.valueOf(maxId));
    }

    if (minId != null) {
      params.put(QueryParam.MIN_ID, String.valueOf(minId));
    }

    if (count != 0) {
      params.put(QueryParam.COUNT, String.valueOf(count));
    }

    if (maxTimeStamp != null) {
      params.put(QueryParam.MAX_TIMESTAMP, String.valueOf(maxTimeStamp.getTime() / 1000));
    }

    if (minTimeStamp != null) {
      params.put(QueryParam.MIN_TIMESTAMP, String.valueOf(minTimeStamp.getTime() / 1000));
    }

    String methodName = String.format(Methods.USERS_RECENT_MEDIA, userId);

    return createInstagramObject(Verbs.GET, MediaFeed.class, methodName, params);
  }
Beispiel #5
0
  /**
   * Get the most recent media published by a user.
   *
   * @param userId userId of the User.
   * @return a MediaFeed object.
   * @throws InstagramException if any error occurs
   */
  public MediaFeed getRecentMediaFeed(String userId) throws InstagramException {
    Preconditions.checkEmptyString(userId, "UserId cannot be null or empty.");

    String methodName = String.format(Methods.USERS_RECENT_MEDIA, userId);

    return createInstagramObject(Verbs.GET, MediaFeed.class, methodName, null);
  }
Beispiel #6
0
  /**
   * Search for a user by name.
   *
   * @param query A query string.
   * @return a UserFeed object.
   * @throws InstagramException if any error occurs.
   */
  public UserFeed searchUser(String query) throws InstagramException {
    Preconditions.checkNotNull(query, "search query cannot be null.");

    Map<String, String> params = new HashMap<String, String>();
    params.put(QueryParam.SEARCH_QUERY, query);

    return createInstagramObject(Verbs.GET, UserFeed.class, Methods.USERS_SEARCH, params);
  }
Beispiel #7
0
  /**
   * Get basic information about a user.
   *
   * @param userId user-id
   * @return a MediaFeed object.
   * @throws InstagramException if any error occurs.
   */
  public UserInfo getUserInfo(long userId) throws InstagramException {
    Preconditions.checkNotNull(userId, "UserId cannot be null.");

    String apiMethod = String.format(Methods.USERS_WITH_ID, userId);
    UserInfo userInfo = createInstagramObject(Verbs.GET, UserInfo.class, apiMethod, null);

    return userInfo;
  }
Beispiel #8
0
  /**
   * Get the list of 'users' the current authenticated user is followed by.
   *
   * @param userId userId of the User.
   * @return a UserFeed object.
   * @throws InstagramException if any error occurs.
   */
  public UserFeed getUserFollowedByList(long userId) throws InstagramException {
    Preconditions.checkNotNull(userId, "userId cannot be null.");

    String apiMethod = String.format(Methods.USERS_ID_FOLLOWED_BY, userId);
    UserFeed userFeed = createInstagramObject(Verbs.GET, UserFeed.class, apiMethod, null);

    return userFeed;
  }
Beispiel #9
0
  /**
   * Get information about the current user's relationship (follow/following/etc) to another user.
   *
   * @param userId userId of the User.
   * @return a Relationship feed object.
   * @throws InstagramException if any error occurs.
   */
  public RelationshipFeed getUserRelationship(String userId) throws InstagramException {
    Preconditions.checkEmptyString(userId, "userId cannot be null or empty.");

    String apiMethod = String.format(Methods.USERS_ID_RELATIONSHIP, userId);
    RelationshipFeed feed =
        createInstagramObject(Verbs.GET, RelationshipFeed.class, apiMethod, null);

    return feed;
  }
Beispiel #10
0
  /**
   * Get the next page for list of 'users' the authenticated is followed by.
   *
   * @param pagination
   * @throws InstagramException
   */
  public UserFeed getUserFollowedByListNextPage(String userId, String cursor)
      throws InstagramException {
    Preconditions.checkEmptyString(userId, "userId cannot be null or empty.");

    Map<String, String> params = new HashMap<String, String>(1);
    if (cursor != null) params.put("cursor", cursor);

    String apiMethod = String.format(Methods.USERS_ID_FOLLOWED_BY, userId);
    UserFeed userFeed = createInstagramObject(Verbs.GET, UserFeed.class, apiMethod, params);

    return userFeed;
  }
Beispiel #11
0
  /**
   * Get basic information about a user.
   *
   * @param userId user-id
   * @return a MediaFeed object.
   * @throws InstagramException if any error occurs.
   */
  public UserInfo getUserInfo(String userId) throws InstagramException {

    LogHelper.logEntrance(logger, "getUserInfo", userId);

    logger.info("Getting user info for : " + userId);

    Preconditions.checkEmptyString(userId, "UserId cannot be null or empty.");

    String apiMethod = String.format(Methods.USERS_WITH_ID, userId);

    return createInstagramObject(Verbs.GET, UserInfo.class, apiMethod, null);
  }