Package com.sola.instagram.io

Examples of com.sola.instagram.io.GetMethod


   */
  public User getUserById(int userId) throws Exception {
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("user_id", userId);
    String uri = uriConstructor.constructUri(UriFactory.Users.GET_DATA, map, true);
    JSONObject userObject = (new GetMethod(uri).call()).getJSON();
    if (userObject.has("data")) {
      return new User(userObject.getJSONObject("data"), getAccessToken());
    } else {
      throw new InstagramException("User with id = " + userId
          + " cannot be accessed" + " or may not exist");
View Full Code Here


   */
  public Media getMedia(String mediaId) throws Exception {
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("media_id", mediaId);
    String uri =  uriConstructor.constructUri(UriFactory.Media.GET_MEDIA, map, true);
    JSONObject object = (new GetMethod(uri).call()).getJSON();
    return Media.fromJSON(object.getJSONObject("data"), getAccessToken());
  }
View Full Code Here

    ArrayList<Media> media = new ArrayList<Media>();
    String uri = UriFactory.Media.SEARCH_MEDIA + "?access_token="
        + getAccessToken() + "&lat=" + latitude + "&lng=" + longitude
        + "&min_timestamp=" + minTimestamp + "&max_timestamp="
        + maxTimestamp + "&distance=" + distance;
    JSONObject object = (new GetMethod(uri)).call().getJSON();
    JSONArray mediaItems = object.getJSONArray("data");
    for (int i = 0; i < mediaItems.length(); i++) {
      media.add(Media.fromJSON(mediaItems.getJSONObject(i), getAccessToken()));
    }
    return media;
View Full Code Here

   * @return List of the most popular media on instagram.
   */
  public List<Media> getPopularMedia() throws Exception {
    ArrayList<Media> media = new ArrayList<Media>();
    String uri = uriConstructor.constructUri(UriFactory.Media.GET_POPULAR_MEDIA, null, true);
    JSONObject object = (new GetMethod().setMethodURI(uri)).call().getJSON();
    JSONArray mediaItems = object.getJSONArray("data");
    for (int i = 0; i < mediaItems.length(); i++) {
      media.add(Media.fromJSON(mediaItems.getJSONObject(i), getAccessToken()));
    }
    return media;
View Full Code Here

   */
  public List<User> searchUsersByName(String name) throws Exception {
    ArrayList<User> users = new ArrayList<User>();
    String uri = uriConstructor.constructUri(UriFactory.Users.SEARCH_USER_BY_NAME, null, true)
           + "&q=" + name;
    JSONArray userObjects = (new GetMethod(uri)).call()
                .getJSON()
                .getJSONArray("data");
    for (int i = 0; i < userObjects.length(); i++) {
      users.add(new User(userObjects.getJSONObject(i), getAccessToken()));
    }
View Full Code Here

  }

  public List<User> getFollowRequests() throws Exception {
    ArrayList<User> users = new ArrayList<User>();
    String uri = uriConstructor.constructUri(UriFactory.Relationships.GET_FOLLOW_REQUESTS, null, true);
    JSONObject object     = (new GetMethod(uri)).call().getJSON();
    JSONArray userObjects = object.getJSONArray("data");
    for (int i = 0; i < userObjects.length(); i++) {
      users.add(new User(userObjects.getJSONObject(i), getAccessToken()));
    }
    return users;
View Full Code Here

  public Relationship getRelationshipWith(int userId) throws Exception {
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("user_id", userId);
    String uri = uriConstructor.constructUri(UriFactory.Relationships.GET_RELATIONSHIP_STATUS, map, true);
    JSONObject object = (new GetMethod(uri)).call().getJSON();
    return new Relationship(object.getJSONObject("data"), getAccessToken());
  }
View Full Code Here

  public Tag getTag(String tagName) throws Exception {
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("tag_name", tagName);
    String uri = uriConstructor.constructUri(UriFactory.Tags.GET_TAG, map, true);
    JSONObject object = (new GetMethod(uri)).call().getJSON();
    return new Tag(object.getJSONObject("data"), getAccessToken());
  }
View Full Code Here

  }

  public List<Tag> searchTags(String tagName) throws Exception {
    String uri = uriConstructor.constructUri(UriFactory.Tags.SEARCH_TAGS, null, true)
             + "&q=" + tagName;
    JSONObject object   = (new GetMethod(uri)).call().getJSON();
    ArrayList<Tag> tags = new ArrayList<Tag>();
    JSONArray tagItems  = object.getJSONArray("data");
    for (int i = 0; i < tagItems.length(); i++) {
      tags.add(new Tag(tagItems.getJSONObject(i), getAccessToken()));
    }
View Full Code Here

  public Location getLocation(int locationId) throws Exception {
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("location_id", locationId);
    String uriString = uriConstructor.constructUri(UriFactory.Locations.GET_LOCATION, map, true);
    JSONObject object = (new GetMethod().setMethodURI(uriString)).call().getJSON();
    return new Location(object.getJSONObject("data"), getAccessToken());
  }
View Full Code Here

TOP

Related Classes of com.sola.instagram.io.GetMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.