Search in sources :

Example 76 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class RateLimitLambda method main.

public static void main(String... args) {
    Twitter twitter = TwitterFactory.getSingleton();
    twitter.onRateLimitStatus(e -> System.out.println("rate limit remaining: " + e.getRateLimitStatus().getRemaining()));
    for (int i = 0; i < 20; i++) {
        try {
            System.out.println(twitter.getHomeTimeline());
        } catch (TwitterException e) {
            e.printStackTrace();
        }
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterException(twitter4j.TwitterException)

Example 77 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class CreateUserListMember method main.

/**
     * Usage: java twitter4j.examples.list.CreateUserListMember [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.CreateUserListMember [list id] [user id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.createUserListMember(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
        System.out.println("Successfully added the user to the specified list.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to add users: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 78 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class CreateUserListMembers method main.

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

Example 79 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class UpdateProfileBackgroundImage method main.

/**
     * Usage: java twitter4j.examples.account.UpdateProfileBackgroundImage [image file path] [tiled('true' or 'false')
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.account.UpdateProfileBackgroundImage [image file path] [tiled('true' or 'false')");
        System.exit(-1);
    }
    boolean tiled = false;
    if (args.length >= 2) {
        tiled = Boolean.parseBoolean(args[1]);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.updateProfileBackgroundImage(new File(args[0]), tiled);
        System.out.println("Successfully updated profile background image.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to update profile background image: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) File(java.io.File) TwitterException(twitter4j.TwitterException)

Example 80 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class UpdateProfileImage method main.

/**
     * Usage: java twitter4j.examples.account.UpdateProfileImage [image file path]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.account.UpdateProfileImage [image file path]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.updateProfileImage(new File(args[0]));
        System.out.println("Successfully updated profile image.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to update profile image: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) File(java.io.File) TwitterException(twitter4j.TwitterException)

Aggregations

TwitterException (twitter4j.TwitterException)96 Twitter (twitter4j.Twitter)69 TwitterFactory (twitter4j.TwitterFactory)54 Status (twitter4j.Status)21 User (twitter4j.User)12 Intent (android.content.Intent)11 ArrayList (java.util.ArrayList)9 File (java.io.File)6 IDs (twitter4j.IDs)6 Context (android.content.Context)5 Date (java.util.Date)4 DirectMessage (twitter4j.DirectMessage)4 Paging (twitter4j.Paging)4 AccessToken (twitter4j.auth.AccessToken)4 Activity (android.app.Activity)3 SharedPreferences (android.content.SharedPreferences)3 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)3 View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3