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()); }
/** * 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; }
/** * 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; }
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); }
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); }
/** * 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; }
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()); }
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); }
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); }
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); }
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); }
/** * 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; }
/** * 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()); }
/** * 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)); }