Example usage for twitter4j TwitterException getMessage

List of usage examples for twitter4j TwitterException getMessage

Introduction

In this page you can find the example usage for twitter4j TwitterException getMessage.

Prototype

@Override
    public String getMessage() 

Source Link

Usage

From source file:com.illusionaryone.TwitterAPI.java

License:Open Source License

public Boolean authenticate() {
    com.gmt2001.Console.debug.println("Attempting to Authenticate");
    try {//from w  ww  .  j a va  2s.c om
        ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
        configurationBuilder.setOAuthConsumerKey(consumerKey);
        configurationBuilder.setOAuthConsumerSecret(consumerSecret);
        configurationBuilder.setOAuthAccessToken(oauthAccessToken);
        configurationBuilder.setOAuthAccessTokenSecret(oauthAccessSecret);

        TwitterFactory twitterFactory = new TwitterFactory(configurationBuilder.build());
        twitter = twitterFactory.getInstance();

        accessToken = twitter.getOAuthAccessToken();
        com.gmt2001.Console.out.println("Authenticated with Twitter API");
        return true;
    } catch (TwitterException ex) {
        com.gmt2001.Console.err.println("Twitter Auth Failed: " + ex.getMessage());
        accessToken = null;
        return false;
    }
}

From source file:com.illusionaryone.TwitterAPI.java

License:Open Source License

public String updateStatus(String statusString) {
    if (accessToken == null) {
        return "false";
    }//from  w w  w.  j  av a 2s. c  o m

    try {
        Status status = twitter.updateStatus(statusString.replaceAll("@", "").replaceAll("#", ""));
        com.gmt2001.Console.debug.println("Success");
        return "true";
    } catch (TwitterException ex) {
        com.gmt2001.Console.err.println("Failed: " + ex.getMessage());
        return "false";
    }
}

From source file:com.illusionaryone.TwitterAPI.java

License:Open Source License

public String updateStatus(String statusString, String filename) {
    if (accessToken == null) {
        return "false";
    }/*  w w  w .ja  v  a 2s.c  o m*/

    try {
        StatusUpdate statusUpdate = new StatusUpdate(statusString.replaceAll("@", "").replaceAll("#", ""));
        statusUpdate.setMedia(new File(filename));
        Status status = twitter.updateStatus(statusUpdate);
        com.gmt2001.Console.debug.println("Success");
        return "true";
    } catch (TwitterException ex) {
        com.gmt2001.Console.err.println("Failed: " + ex.getMessage());
        return "false";
    }
}

From source file:com.illusionaryone.TwitterAPI.java

License:Open Source License

public List<Status> getUserTimeline(long sinceId) {
    if (accessToken == null) {
        com.gmt2001.Console.debug.println("Access Token is NULL");
        return null;
    }/*from  w w w. ja  va 2 s  .c om*/

    try {
        com.gmt2001.Console.debug.println("Polling Data");
        if (sinceId != 0L) {
            Paging paging = new Paging(sinceId);
            List<Status> statuses = twitter.getUserTimeline(paging);
            if (statuses.isEmpty()) {
                return null;
            }
            return statuses;
        } else {
            List<Status> statuses = twitter.getUserTimeline();
            if (statuses.isEmpty()) {
                return null;
            }
            return statuses;
        }
    } catch (TwitterException ex) {
        com.gmt2001.Console.err.println("Failed: " + ex.getMessage());
        return null;
    }
}

From source file:com.illusionaryone.TwitterAPI.java

License:Open Source License

public String getUserTimeline(String username) {
    if (accessToken == null) {
        com.gmt2001.Console.debug.println("Access Token is NULL");
        return null;
    }//www . j  a  v  a2 s.  c  o  m

    try {
        com.gmt2001.Console.debug.println("Polling Data");
        List<Status> statuses = twitter.getUserTimeline(username);
        if (statuses.isEmpty()) {
            return null;
        }
        return statuses.get(0).getText();
    } catch (TwitterException ex) {
        com.gmt2001.Console.err.println("Failed: " + ex.getMessage());
        return null;
    }
}

From source file:com.illusionaryone.TwitterAPI.java

License:Open Source License

public List<Status> getHomeTimeline(long sinceId) {
    if (accessToken == null) {
        com.gmt2001.Console.debug.println("Access Token is NULL");
        return null;
    }//from   ww  w.j  a  v  a2 s  .c om

    try {
        com.gmt2001.Console.debug.println("Polling Data");
        if (sinceId != 0L) {
            Paging paging = new Paging(sinceId);
            List<Status> statuses = twitter.getHomeTimeline(paging);
            if (statuses.isEmpty()) {
                return null;
            }
            return statuses;
        } else {
            List<Status> statuses = twitter.getHomeTimeline();
            if (statuses.isEmpty()) {
                return null;
            }
            return statuses;
        }
    } catch (TwitterException ex) {
        com.gmt2001.Console.err.println("Failed: " + ex.getMessage());
        return null;
    }
}

From source file:com.illusionaryone.TwitterAPI.java

License:Open Source License

public List<Status> getRetweetsOfMe(long sinceId) {
    if (accessToken == null) {
        com.gmt2001.Console.debug.println("Access Token is NULL");
        return null;
    }/*from  ww  w. j  ava  2  s  .  c  o  m*/

    try {
        com.gmt2001.Console.debug.println("Polling Data");
        if (sinceId != 0L) {
            Paging paging = new Paging(sinceId);
            List<Status> statuses = twitter.getRetweetsOfMe(paging);
            if (statuses.isEmpty()) {
                return null;
            }
            return statuses;
        } else {
            List<Status> statuses = twitter.getRetweetsOfMe();
            if (statuses.isEmpty()) {
                return null;
            }
            return statuses;
        }
    } catch (TwitterException ex) {
        com.gmt2001.Console.err.println("Failed: " + ex.getMessage());
        return null;
    }
}

From source file:com.illusionaryone.TwitterAPI.java

License:Open Source License

public List<Status> getRetweets(long statusId) {
    if (accessToken == null) {
        com.gmt2001.Console.debug.println("Access Token is NULL");
        return null;
    }//from   w w w.  j  a  v a 2  s  . c  om

    try {
        com.gmt2001.Console.debug.println("Polling Data");
        List<Status> statuses = twitter.getRetweets(statusId);
        if (statuses.isEmpty()) {
            return null;
        }
        return statuses;
    } catch (TwitterException ex) {
        com.gmt2001.Console.err.println("Failed: " + ex.getMessage());
        return null;
    }
}

From source file:com.illusionaryone.TwitterAPI.java

License:Open Source License

public List<Status> getMentions(long sinceId) {
    if (accessToken == null) {
        com.gmt2001.Console.debug.println("Access Token is NULL");
        return null;
    }/*  ww w.ja  va2s  . c  om*/

    try {
        com.gmt2001.Console.debug.println("Polling Data");
        if (sinceId != 0L) {
            Paging paging = new Paging(sinceId);
            List<Status> statuses = twitter.getMentionsTimeline(paging);
            if (statuses.isEmpty()) {
                return null;
            }
            return statuses;
        } else {
            List<Status> statuses = twitter.getMentionsTimeline();
            if (statuses.isEmpty()) {
                return null;
            }
            return statuses;
        }
    } catch (TwitterException ex) {
        com.gmt2001.Console.err.println("Failed: " + ex.getMessage());
        return null;
    }
}

From source file:com.itbs.aimcer.commune.twitter.TwitterConnection.java

License:Open Source License

public boolean removeContact(Nameable contact, Group group) {
    try {//from   w w w .jav a 2s .  c  om
        connection.destroyFriendship(fixUserName(contact.getName()));
        return true;
    } catch (TwitterException e) {
        notifyErrorOccured("Failed to break a friendship\n" + e.getMessage(), e);
    }
    return false;
}