use of twitter4j.TwitterException in project twitter4j by yusuke.
the class LoadRawJSON method main.
/**
* Usage: java twitter4j.examples.json.LoadRawJSON
*
* @param args String[]
*/
public static void main(String[] args) {
try {
File[] files = new File("statuses").listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".json");
}
});
for (File file : files) {
String rawJSON = readFirstLine(file);
Status status = TwitterObjectFactory.createStatus(rawJSON);
System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
}
System.exit(0);
} catch (IOException ioe) {
ioe.printStackTrace();
System.out.println("Failed to store tweets: " + ioe.getMessage());
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to get timeline: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterException in project twitter4j by yusuke.
the class CreateUserList method main.
/**
* Usage: java twitter4j.examples.list.CreateUserList [list name] [list description]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.list.CreateUserList [list name] [list description]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
String description = null;
if (args.length >= 2) {
description = args[1];
}
UserList list = twitter.createUserList(args[0], true, description);
System.out.println("Successfully created a list (id:" + list.getId() + ", slug:" + list.getSlug() + ").");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to create a list: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterException in project twitter4j by yusuke.
the class CreateUserListSubscription method main.
/**
* Usage: java twitter4j.examples.list.CreateUserListSubscription [list id]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.list.CreateUserListSubscription [list id]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
twitter.createUserListSubscription(Integer.parseInt(args[0]));
System.out.println("Successfully subscribed the list.");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to subscribe the list: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterException in project twitter4j by yusuke.
the class DestroyUserList method main.
/**
* Usage: java twitter4j.examples.list.DestroyUserList [list id]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.list.DestroyUserList [list id]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
UserList list = twitter.destroyUserList(Integer.parseInt(args[0]));
System.out.println("Successfully deleted the list (id:" + list.getId() + ", slug:" + list.getSlug() + ").");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to delete a list: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterException in project twitter4j by yusuke.
the class ShowUserList method main.
/**
* Usage: java twitter4j.examples.list.ShowUserList [list id]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.list.ShowUserList [list id]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
UserList list = twitter.showUserList(Integer.parseInt(args[0]));
System.out.println("id:" + list.getId() + ", name:" + list.getName() + ", description:" + list.getDescription() + ", slug:" + list.getSlug() + "");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to show the list: " + te.getMessage());
System.exit(-1);
}
}
Aggregations