Search in sources :

Example 61 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class GetRetweets method main.

/**
     * Usage: java twitter4j.examples.tweets.GetRetweets [status id]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.tweets.GetRetweets [status id]");
        System.exit(-1);
    }
    System.out.println("Showing up to 100 of the first retweets of the status id - [" + args[0] + "].");
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        List<Status> statuses = twitter.getRetweets(Long.parseLong(args[0]));
        for (Status status : statuses) {
            System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
        }
        System.out.println("done.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get retweets: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Status(twitter4j.Status) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 62 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class RetweetStatus method main.

/**
     * Usage: java twitter4j.examples.tweets.RetweetStatus [status id]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.tweets.RetweetStatus [status id]");
        System.exit(-1);
    }
    System.out.println("Retweeting the status id - [" + args[0] + "].");
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.retweetStatus(Long.parseLong(args[0]));
        System.out.println("Successfully retweeted status [" + args[0] + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to retweet: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 63 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class DeleteUserListMember method main.

/**
     * Usage: java twitter4j.examples.list.DeleteUserListMember [list id] [user id]
     *
     * @param args message
     */
public static void main(String[] args) {
    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());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 64 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class DestroyUserListSubscription method main.

/**
     * Usage: java twitter4j.examples.list.DestroyUserListSubscription [list id]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.list.DestroyUserListSubscription [list id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.destroyUserListSubscription(Integer.parseInt(args[0]));
        System.out.println("Successfully unsubscribed the list.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to unsubscribe the list: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 65 with TwitterFactory

use of twitter4j.TwitterFactory in project intellij-community by JetBrains.

the class StudyTwitterUtils method getTwitter.

/**
   * Set consumer key and secret. 
   * @return Twitter instance with consumer key and secret set.
   */
@NotNull
public static Twitter getTwitter(@NotNull final String consumerKey, @NotNull final String consumerSecret) {
    ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
    configurationBuilder.setOAuthConsumerKey(consumerKey);
    configurationBuilder.setOAuthConsumerSecret(consumerSecret);
    return new TwitterFactory(configurationBuilder.build()).getInstance();
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) TwitterFactory(twitter4j.TwitterFactory) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TwitterFactory (twitter4j.TwitterFactory)68 Twitter (twitter4j.Twitter)60 TwitterException (twitter4j.TwitterException)55 ConfigurationBuilder (twitter4j.conf.ConfigurationBuilder)10 Status (twitter4j.Status)7 IDs (twitter4j.IDs)6 AccessToken (twitter4j.auth.AccessToken)5 SavedSearch (twitter4j.SavedSearch)4 RequestToken (twitter4j.auth.RequestToken)4 Configuration (twitter4j.conf.Configuration)4 File (java.io.File)3 User (twitter4j.User)3 UserList (twitter4j.UserList)3 Intent (android.content.Intent)2 AppSettings (com.klinker.android.twitter.settings.AppSettings)2 HttpServletRouter (h2weibo.HttpServletRouter)2 HashMap (java.util.HashMap)2 HttpSession (javax.servlet.http.HttpSession)2 AccessToken (twitter4j.http.AccessToken)2 AlarmManager (android.app.AlarmManager)1