Example #1
0
 public ReadableResponse signedCustomRequest(
     String httpMethod, String request, Map<String, String> bodyParams)
     throws NotAuthentifiedException {
   if (!isAuthentified()) throw new NotAuthentifiedException(NETWORK);
   Request requestObj = new Request(Utils.getScribeVerb(httpMethod), request);
   Utils.addBodyParams(requestObj, bodyParams);
   return new ScribeResponseWrapper(requestObj.send());
 }
Example #2
0
 /**
  * Extracts a list of users
  *
  * @param response an XML-formatted response
  * @return the list of users
  * @throws SAXException
  * @throws ParserConfigurationException
  * @throws IOException
  */
 @SuppressWarnings("unchecked")
 public List<TwitterUser> readUsers(ReadableResponse response)
     throws SAXException, ParserConfigurationException, IOException {
   List<TwitterUser> list =
       (List<TwitterUser>) Utils.parseXML(response, new TwitterParsingUsers());
   return list;
 }
Example #3
0
 /**
  * Extracts a URL
  *
  * @param response an XML-formatted response
  * @return the URL extracted
  * @throws SAXException
  * @throws ParserConfigurationException
  * @throws IOException
  */
 @SuppressWarnings("unchecked")
 public String readUrl(ReadableResponse response)
     throws SAXException, ParserConfigurationException, IOException {
   List<String> list = (List<String>) Utils.parseXML(response, new TwitterParsingUrl());
   if (list.size() == 1) return list.get(0);
   return null;
 }
Example #4
0
 public List<BuzzActivity> getWallPosts()
     throws NotAuthentifiedException, OAuthMessageSignerException, OAuthExpectationFailedException,
         OAuthCommunicationException, ClientProtocolException, IOException, JSONException {
   if (!isAuthentified()) throw new NotAuthentifiedException(NETWORK);
   ReadableResponse response = Utils.signedGetRequest(GET_WALLPOSTS, httpOauthConsumer, null);
   return reader.readActivities(response);
 }
Example #5
0
 public List<BuzzUser> getFollowed()
     throws ClientProtocolException, IOException, NotAuthentifiedException,
         OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException,
         JSONException {
   if (!isAuthentified()) throw new NotAuthentifiedException(NETWORK);
   ReadableResponse response = Utils.signedGetRequest(GET_FOLLOWED, httpOauthConsumer, null);
   return reader.readUsers(response);
 }
Example #6
0
 /**
  * Extracts a single LinkedInUser
  *
  * @param response an XML-formatted response
  * @return the target user
  * @throws SAXException
  * @throws ParserConfigurationException
  * @throws IOException
  */
 @SuppressWarnings("unchecked")
 public LinkedInUser readUser(ReadableResponse response)
     throws SAXException, ParserConfigurationException, IOException {
   List<LinkedInUser> list =
       (List<LinkedInUser>) Utils.parseXML(response, new LinkedInParsingUsers(true));
   if (list.size() == 1) return list.get(0);
   else return null;
 }
Example #7
0
 public ReadableResponse customRequest(
     String httpMethod, String request, Map<String, String> bodyParams) {
   Request requestObj = new Request(Utils.getScribeVerb(httpMethod), request);
   for (Iterator<String> it = bodyParams.keySet().iterator(); it.hasNext(); ) {
     String key = it.next();
     requestObj.addBodyParameter(key, bodyParams.get(key));
   }
   return new ScribeResponseWrapper(requestObj.send());
 }
Example #8
0
 public BuzzUser getUser(String identifier)
     throws JSONException, OAuthMessageSignerException, OAuthExpectationFailedException,
         OAuthCommunicationException, ClientProtocolException, IOException,
         NotAuthentifiedException {
   if (!isAuthentified()) throw new NotAuthentifiedException(NETWORK);
   ReadableResponse response =
       Utils.signedGetRequest(GET_USER1 + identifier + GET_USER2, httpOauthConsumer, null);
   return reader.readUser(response);
 }
Example #9
0
 public boolean like(Post post)
     throws NotAuthentifiedException, OAuthMessageSignerException, OAuthExpectationFailedException,
         OAuthCommunicationException, ClientProtocolException, IOException, JSONException {
   String id = post.getId();
   if (!isAuthentified()) throw new NotAuthentifiedException(NETWORK);
   ReadableResponse response =
       Utils.signedRequest(
           PUT, PUT_LIKE + id, httpOauthConsumer, JSON_TYPE, new ArrayList<NameValuePair>());
   return reader.readResponse(response);
 }
Example #10
0
  public boolean post(String content)
      throws NotAuthentifiedException, OAuthMessageSignerException, OAuthExpectationFailedException,
          OAuthCommunicationException, ClientProtocolException, IOException, JSONException {
    if (!isAuthentified()) throw new NotAuthentifiedException(NETWORK);

    ReadableResponse response =
        Utils.signedPostRequest(
            POST_ACTIVITY, JSON_ENTITY1 + content + JSON_ENTITY2, httpOauthConsumer, JSON_TYPE);
    return reader.readResponse(response);
  }
Example #11
0
 public boolean comment(Post post, String comment)
     throws FileNotFoundException, MalformedURLException, IOException, NotAuthentifiedException,
         OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException,
         JSONException {
   if (!isAuthentified()) throw new NotAuthentifiedException(NETWORK);
   String entity = XML_ENTITY1 + comment + XML_ENTITY2;
   ReadableResponse response =
       Utils.signedRequest(
           POST2, POST_COMMENT + post.getId() + COMMENTS, httpOauthConsumer, XML_TYPE, entity);
   return reader.readResponse(response);
 }
Example #12
0
 /**
  * Determines whether an action was successful or not The message of the response is printed on
  * the debug output
  *
  * @param response an XML-formatted response
  * @return true if the operation was successful
  * @throws SAXException
  * @throws ParserConfigurationException
  * @throws IOException
  * @throws OperationException
  */
 @SuppressWarnings("unchecked")
 public boolean readResponse(ReadableResponse response)
     throws SAXException, ParserConfigurationException, IOException, OperationException {
   List<String> list = (List<String>) Utils.parseXML(response, new TwitterParsingResponse());
   if (list.size() == 1) {
     if (list.get(0).equals("true")) {
       return true;
     } else if (list.get(0).equals("false")) {
       return false;
     } else {
       throw new OperationException(list.get(0));
     }
   }
   return false;
 }
Example #13
0
 /**
  * Extracts a list of LinkedInConnectionPosts
  *
  * @param response an XML-formatted response
  * @return the list of connection posts
  * @throws SAXException
  * @throws ParserConfigurationException
  * @throws IOException
  */
 @SuppressWarnings("unchecked")
 public List<LinkedInConnectionPost> readConnectionPosts(ReadableResponse response)
     throws SAXException, ParserConfigurationException, IOException {
   return (List<LinkedInConnectionPost>)
       Utils.parseXML(response, new LinkedInParsingConnectionPosts());
 }
Example #14
0
 /**
  * Extracts a list of LinkedInUsers
  *
  * @param response an XML-formatted response
  * @return the list of users
  * @throws SAXException
  * @throws ParserConfigurationException
  * @throws IOException
  */
 @SuppressWarnings("unchecked")
 public List<LinkedInUser> readUsers(ReadableResponse response)
     throws SAXException, ParserConfigurationException, IOException {
   return (List<LinkedInUser>) Utils.parseXML(response, new LinkedInParsingUsers(false));
 }