Package com.sola.instagram.exception

Examples of com.sola.instagram.exception.InstagramException


    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


    return this;
  }

  public String getAuthorizationUri() throws InstagramException {
    if (getClientId() == null || getRedirectUri() == null) {
      throw new InstagramException("Please make sure that the "
          + "clientId and redirectUri fields are set");
    }
    HashMap<String, Object> args = new HashMap<String, Object>();
    args.put("client_id", getClientId());
    args.put("redirect_uri", getRedirectUri());
View Full Code Here

  }

  public AccessToken build(String code) throws Exception {
    if (getClientSecret() == null || getClientId() == null
        || getRedirectUri() == null) {
      throw new InstagramException("Please make sure that the"
          + "clientId, clientSecret and redirectUri fields are set");
    }
    HashMap<String, Object> postArgs = new HashMap<String, Object>();
    postArgs.put("client_id", getClientId());
    postArgs.put("client_secret", getClientSecret());
    postArgs.put("grant_type", "authorization_code");
    postArgs.put("redirect_uri", getRedirectUri());
    if(getScope() != null && getScope() != "" ) {
      postArgs.put("scope", getScope());
    }
    postArgs.put("code", code);

   
      JSONObject response = (new PostMethod() .setPostParameters(postArgs)
      .setMethodURI(UriFactory.Auth.GET_ACCESS_TOKEN) ).call().getJSON();
    
    try {
      setAccessToken(new
          AccessToken(response.getString("access_token")));
       setSessionUser(new User(response.getJSONObject("user"),
           getAccessToken().getTokenString()));
    } catch (Exception e) {
      throw new InstagramException("JSON parsing error");
    }
    return getAccessToken();
  }
View Full Code Here

    return getAccessToken();
  }

  public AccessToken getAccessToken() throws InstagramException {
    if (accessToken == null)
      throw new InstagramException(
          "Token has not been fetched, please call build(String code) "
              + "before calling getAccessToken()");
    else
      return accessToken;
  }
View Full Code Here

    this.accessToken = accessToken;
  }

  public User getAuthenticatedUser() throws InstagramException {
    if (accessToken == null)
      throw new InstagramException(
          "No user has been authenticated yet");
    else
      return sessionUser;
  }
View Full Code Here

          likers.add(new User(likerUserObjects.getJSONObject(i), accessToken));
        }
        setLikers(likers);
       
      } catch(JSONException e) {
        throw new InstagramException("JSON parsing error");
      }
    }
    return likers;
  }
View Full Code Here

TOP

Related Classes of com.sola.instagram.exception.InstagramException

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.