use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class VerifyCredentials method main.
/**
* Usage: java twitter4j.examples.account.VerifyCredentials
*
* @param args message
*/
public static void main(String[] args) {
try {
Twitter twitter = new TwitterFactory().getInstance();
User user = twitter.verifyCredentials();
System.out.println("Successfully verified credentials of " + user.getScreenName());
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to verify credentials: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class GetBlockingUsers method main.
/**
* Usage: java twitter4j.examples.block.GetBlockingUsers
*
* @param args message
*/
public static void main(String[] args) {
try {
Twitter twitter = new TwitterFactory().getInstance();
int page = 1;
List<User> users;
do {
users = twitter.getBlocksList(page);
for (User user : users) {
System.out.println("@" + user.getScreenName());
}
page++;
// this code ends up in an infinite loop due to the issue 1988
// http://code.google.com/p/twitter-api/issues/detail?id=1988
} while (users.size() > 0 && page <= 10);
System.out.println("done.");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to get blocking users: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class SendDirectMessage method main.
/**
* Usage: java twitter4j.examples.directMessage.DirectMessage [recipient screen name] [message]
*
* @param args String[]
*/
public static void main(String[] args) {
if (args.length < 2) {
System.out.println("Usage: java twitter4j.examples.directmessage.SendDirectMessage [recipient screen name] [message]");
System.exit(-1);
}
Twitter twitter = new TwitterFactory().getInstance();
try {
DirectMessage message = twitter.sendDirectMessage(args[0], args[1]);
System.out.println("Direct message successfully sent to " + message.getRecipientScreenName());
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to send a direct message: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class GetFollowersIDs method main.
/**
* Usage: java twitter4j.examples.friendsandfollowers.GetFollowersIDs [screen name]
*
* @param args message
*/
public static void main(String[] args) {
try {
Twitter twitter = new TwitterFactory().getInstance();
long cursor = -1;
IDs ids;
System.out.println("Listing followers's ids.");
do {
if (0 < args.length) {
ids = twitter.getFollowersIDs(args[0], cursor);
} else {
ids = twitter.getFollowersIDs(cursor);
}
for (long id : ids.getIDs()) {
System.out.println(id);
}
} while ((cursor = ids.getNextCursor()) != 0);
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to get followers' ids: " + te.getMessage());
System.exit(-1);
}
}
use of twitter4j.TwitterFactory in project twitter4j by yusuke.
the class GetFriendsIDs method main.
/**
* Usage: java twitter4j.examples.friendsandfollowers.GetFriendsIDs [screen name]
*
* @param args message
*/
public static void main(String[] args) {
try {
Twitter twitter = new TwitterFactory().getInstance();
long cursor = -1;
IDs ids;
System.out.println("Listing following ids.");
do {
if (0 < args.length) {
ids = twitter.getFriendsIDs(args[0], cursor);
} else {
ids = twitter.getFriendsIDs(cursor);
}
for (long id : ids.getIDs()) {
System.out.println(id);
}
} while ((cursor = ids.getNextCursor()) != 0);
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to get friends' ids: " + te.getMessage());
System.exit(-1);
}
}
Aggregations