Search in sources :

Example 36 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class ShowStatus method main.

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

Example 37 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class UploadMultipleImages method main.

/**
     * Usage: java twitter4j.examples.tweets.UploadMultipleImages [text] [file1] [file2] ...
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.tweets.UploadMultipleImages [text] [file1] [file2] ...");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long[] mediaIds = new long[args.length - 1];
        for (int i = 1; i < args.length; i++) {
            System.out.println("Uploading...[" + i + "/" + (args.length - 1) + "][" + args[i] + "]");
            UploadedMedia media = twitter.uploadMedia(new File(args[i]));
            System.out.println("Uploaded: id=" + media.getMediaId() + ", w=" + media.getImageWidth() + ", h=" + media.getImageHeight() + ", type=" + media.getImageType() + ", size=" + media.getSize());
            mediaIds[i - 1] = media.getMediaId();
        }
        StatusUpdate update = new StatusUpdate(args[0]);
        update.setMediaIds(mediaIds);
        Status status = twitter.updateStatus(update);
        System.out.println("Successfully updated the status to [" + status.getText() + "][" + status.getId() + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to update status: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : StatusUpdate(twitter4j.StatusUpdate) Status(twitter4j.Status) UploadedMedia(twitter4j.UploadedMedia) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) File(java.io.File) TwitterException(twitter4j.TwitterException)

Example 38 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class CreateFavorite method main.

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

Example 39 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class DestroyFavorite method main.

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

Example 40 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class GetFavorites method main.

/**
     * Usage: java twitter4j.examples.favorite.GetFavorites
     *
     * @param args message
     */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        List<Status> statuses = twitter.getFavorites();
        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 favorites: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Status(twitter4j.Status) 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