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();
}
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations