Search in sources :

Example 56 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class DestroyDirectMessage method main.

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

Example 57 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class ShowDirectMessage method main.

/**
     * Usage: java twitter4j.examples.directmessage.ShowDirectMessage [message id]
     *
     * @param args String[]
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.directmessage.ShowDirectMessage [message id]");
        System.exit(-1);
    }
    Twitter twitter = new TwitterFactory().getInstance();
    try {
        DirectMessage message = twitter.showDirectMessage(Long.parseLong(args[0]));
        System.out.println("From: @" + message.getSenderScreenName() + " id:" + message.getId() + " - " + message.getText());
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get message: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : DirectMessage(twitter4j.DirectMessage) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 58 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class DestroySavedSearch method main.

/**
     * Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        SavedSearch savedSearch = twitter.destroySavedSearch(Integer.parseInt(args[0]));
        System.out.println("Successfully deleted saved search [name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to delete the saved search: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : SavedSearch(twitter4j.SavedSearch) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 59 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class GetSavedSearches method main.

/**
     * Usage: java twitter4j.examples.savedsearches.GetSavedSearches
     *
     * @param args message
     */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        List<SavedSearch> savedSearches = twitter.getSavedSearches();
        for (SavedSearch savedSearch : savedSearches) {
            System.out.println("[name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]");
        }
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to retrieve saved searches: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : SavedSearch(twitter4j.SavedSearch) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 60 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class ReportSpam method main.

/**
     * Usage: java twitter4j.examples.spamreporting.ReportSpam [screen name]
     *
     * @param args String[]
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("java twitter4j.examples.spamreporting.ReportSpam [screen name]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        System.out.println("Successfully reported @" + twitter.reportSpam(args[0]).getScreenName() + " as a spammer.");
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to report spam: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

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