Package twitter4j

Examples of twitter4j.Twitter


@SuppressWarnings("serial") public class LoginTwitterCallbackServlet extends HttpServlet {
  private static Logger log = Logger.getLogger(LoginTwitterCallbackServlet.class.getName());

  public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {

    Twitter twitter =    new TwitterFactory().getInstance();
    String key = AuthenticationProvider.getProp("twitter-consumer-key");
    String secret = AuthenticationProvider.getProp("twitter-consumer-secret");
   

    RequestToken token = (RequestToken) request.getSession().getAttribute("requestToken");
    String verifier = request.getParameter("oauth_verifier");
    twitter.setOAuthConsumer(key, secret);

    try {
      twitter.getOAuthAccessToken(token, verifier);
      User user = twitter.verifyCredentials();
      log.info("Twitter user found:" + user.getName());
      request.getSession().removeAttribute("requestToken");
      String sid = ((Integer) user.getId()).toString();

      UserAccount u = new UserAccount(sid, AuthenticationProvider.TWITTER);
View Full Code Here


            else
                noticiaBC.insert(noticia);
           
            if (shareOnTwitter == true) {
                try {
                    Twitter twitter = TwitterUtil.getTwitter(TwitterUtil.convert(getSite()));
                    twitter.updateStatus("Notícia Postada: '" + noticia.getNtcTitulo() + "'. Acesse o site e confira.");
                } catch (TwitterException ex) {
                    messageContext.add("Erro ao Enviar para Twitter.", SeverityType.WARN);
                }
                shareOnTwitter = false;
            }
View Full Code Here

        if (args.length < 1) {
            System.out.println("Usage: java twitter4j.examples.block.DestroyBlock [screen name]");
            System.exit(-1);
        }
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            twitter.destroyBlock(args[0]);
            System.out.println("Successfully unblocked user [" + args[0] + "].");
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to unblock user: " + te.getMessage());
View Full Code Here

     *
     * @param args message
     */
    public static void main(String[] args) {
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            int page = 1;
            List<User> users;
            do {
                users = twitter.getBlocksList(page);
                for (User user : users) {
                    System.out.println("@" + user.getScreenName());
                }
                page++;
                // this code ends up in an infinite loop due to the issue 1988
View Full Code Here

        if (args.length < 2) {
            System.out.println("Usage: java twitter4j.examples.list.CreateUserListMembers [list id] [screen name[,screen name..]]");
            System.exit(-1);
        }
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            twitter.createUserListMembers(Integer.parseInt(args[0]), args[1].split(","));
            System.out.println("Successfully added the user(s) to the specified list.");
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to add a user: " + te.getMessage());
View Full Code Here

        if (args.length < 3) {
            System.out.println("Usage: java twitter4j.examples.list.UpdateUserList [list id] [new list name] [new description]");
            System.exit(-1);
        }
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            twitter.updateUserList(Integer.parseInt(args[0]), args[1], true, args[2]);
            System.out.println("Successfully updated list [" + args[0] + "].");
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to update list: " + te.getMessage());
View Full Code Here

        if (args.length < 2) {
            System.out.println("Usage: java twitter4j.examples.list.DeleteUserListMember [list id] [user id]");
            System.exit(-1);
        }
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            twitter.destroyUserListMember(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
            System.out.println("Successfully deleted user [" + args[1] + "] from the list.");
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to delete user: " + te.getMessage());
View Full Code Here

            System.out.println(
                    "Usage: java twitter4j.examples.user.UpdateFriendship [screen name] [enable device notification(true|false)] [enable retweets(true|false)]");
            System.exit(-1);
        }
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            Relationship relationship = twitter.updateFriendship(args[0]
                    , Boolean.parseBoolean(args[1]), Boolean.parseBoolean(args[2]));
            System.out.println("Successfully updated the friendship of [" + relationship.getTargetUserScreenName() + "].");
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
View Full Code Here

     *
     * @param args message
     */
    public static void main(String[] args) {
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            long cursor = -1;
            IDs ids;
            System.out.println("Showing incoming pending follow request(s).");
            do {
                ids = twitter.getIncomingFriendships(cursor);
                for (long id : ids.getIDs()) {
                    System.out.println(id);
                }
            } while ((cursor = ids.getNextCursor()) != 0);
            System.exit(0);
View Full Code Here

        if (args.length < 2) {
            System.out.println("Usage: java twitter4j.examples.friendship.ShowFriendship [source screen name] [target screen name]");
            System.exit(-1);
        }
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            Relationship relationship = twitter.showFriendship(args[0], args[1]);
            System.out.println("isSourceBlockingTarget: " + relationship.isSourceBlockingTarget());
            System.out.println("isSourceFollowedByTarget: " + relationship.isSourceFollowedByTarget());
            System.out.println("isSourceFollowingByTarget: " + relationship.isSourceFollowingTarget());
            System.out.println("isSourceNotificationsEnabled: " + relationship.isSourceNotificationsEnabled());
            System.out.println("canSourceDm: " + relationship.canSourceDm());
View Full Code Here

TOP

Related Classes of twitter4j.Twitter

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.