use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class GetRetweets method main.
/**
* Usage: java twitter4j.examples.tweets.GetRetweets [status id]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.tweets.GetRetweets [status id]");
System.exit(-1);
}
System.out.println("Showing up to 100 of the first retweets of the status id - [" + args[0] + "].");
try {
Twitter twitter = new TwitterFactory().getInstance();
List<Status> statuses = twitter.getRetweets(Long.parseLong(args[0]));
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 retweets: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class RetweetStatus method main.
/**
* Usage: java twitter4j.examples.tweets.RetweetStatus [status id]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.tweets.RetweetStatus [status id]");
System.exit(-1);
}
System.out.println("Retweeting the status id - [" + args[0] + "].");
try {
Twitter twitter = new TwitterFactory().getInstance();
twitter.retweetStatus(Long.parseLong(args[0]));
System.out.println("Successfully retweeted status [" + args[0] + "].");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to retweet: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class DeleteUserListMember method main.
/**
* Usage: java twitter4j.examples.list.DeleteUserListMember [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.DeleteUserListMember [list id] [user id]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
twitter.destroyUserListMember(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
System.out.println("Successfully deleted user [" + args[1] + "] from the list.");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to delete user: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class DestroyUserListSubscription method main.
/**
* Usage: java twitter4j.examples.list.DestroyUserListSubscription [list id]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.list.DestroyUserListSubscription [list id]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
twitter.destroyUserListSubscription(Integer.parseInt(args[0]));
System.out.println("Successfully unsubscribed the list.");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to unsubscribe the list: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project intellij-community by JetBrains.
the class StudyTwitterUtils method getTwitter.
/**
* Set consumer key and secret.
* @return Twitter instance with consumer key and secret set.
*/
@NotNull
public static Twitter getTwitter(@NotNull final String consumerKey, @NotNull final String consumerSecret) {
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setOAuthConsumerKey(consumerKey);
configurationBuilder.setOAuthConsumerSecret(consumerSecret);
return new TwitterFactory(configurationBuilder.build()).getInstance();
}
Aggregations