use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class DestroyDirectMessage method main.
/**
* Usage: java twitter4j.examples.directmessages.DestroyDirectMessage [message id]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.directmessages.DestroyDirectMessage [message id]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
twitter.destroyDirectMessage(Long.parseLong(args[0]));
System.out.println("Successfully deleted message [" + args[0] + "].");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to delete message: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class ShowDirectMessage method main.
/**
* Usage: java twitter4j.examples.directmessage.ShowDirectMessage [message id]
*
* @param args String[]
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.directmessage.ShowDirectMessage [message id]");
System.exit(-1);
}
Twitter twitter = new TwitterFactory().getInstance();
try {
DirectMessage message = twitter.showDirectMessage(Long.parseLong(args[0]));
System.out.println("From: @" + message.getSenderScreenName() + " id:" + message.getId() + " - " + message.getText());
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to get message: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class DestroySavedSearch method main.
/**
* Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id]
*
* @param args message
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
SavedSearch savedSearch = twitter.destroySavedSearch(Integer.parseInt(args[0]));
System.out.println("Successfully deleted saved search [name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to delete the saved search: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class GetSavedSearches method main.
/**
* Usage: java twitter4j.examples.savedsearches.GetSavedSearches
*
* @param args message
*/
public static void main(String[] args) {
try {
Twitter twitter = new TwitterFactory().getInstance();
List<SavedSearch> savedSearches = twitter.getSavedSearches();
for (SavedSearch savedSearch : savedSearches) {
System.out.println("[name:" + savedSearch.getName() + " query:" + savedSearch.getQuery() + " id:" + savedSearch.getId() + "]");
}
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to retrieve saved searches: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class ReportSpam method main.
/**
* Usage: java twitter4j.examples.spamreporting.ReportSpam [screen name]
*
* @param args String[]
*/
public static void main(String[] args) {
if (args.length < 1) {
System.out.println("java twitter4j.examples.spamreporting.ReportSpam [screen name]");
System.exit(-1);
}
try {
Twitter twitter = new TwitterFactory().getInstance();
System.out.println("Successfully reported @" + twitter.reportSpam(args[0]).getScreenName() + " as a spammer.");
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to report spam: " + te.getMessage());
System.exit(-1);
}
}
Aggregations