Search in sources :

Example 41 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class CreateFriendship method main.

/**
     * Usage: java twitter4j.examples.friendship.CreateFriendship [screen name]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.friendship.CreateFriendship [screen name]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.createFriendship(args[0]);
        System.out.println("Successfully followed [" + args[0] + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to follow: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 42 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class DestroyFriendship method main.

/**
     * Usage: java twitter4j.examples.friendship.DestroyFriendship [screen name]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.friendship.DestroyFriendship [screen name]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.destroyFriendship(args[0]);
        System.out.println("Successfully unfollowed [" + args[0] + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to unfollow: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 43 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class GetIncomingFriendships method main.

/**
     * Usage: java twitter4j.examples.friendship.GetIncomingFriendships
     *
     * @param args message
     */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        IDs ids;
        System.out.println("Showing incoming pending follow request(s).");
        do {
            ids = twitter.getIncomingFriendships(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 incoming friendships: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) IDs(twitter4j.IDs) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 44 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class GetOutgoingFriendships method main.

/**
     * Usage: java twitter4j.examples.friendship.GetOutgoingFriendships
     *
     * @param args message
     */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        IDs ids;
        System.out.println("Showing outgoing pending follow request(s).");
        do {
            ids = twitter.getOutgoingFriendships(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 outgoing friendships: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) IDs(twitter4j.IDs) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 45 with TwitterFactory

use of twitter4j.TwitterFactory in project twitter4j by yusuke.

the class UpdateFriendship method main.

/**
     * Usage: java twitter4j.examples.user.UpdateFriendship [screen name] [enable device notification(true|false)] [enable retweets(true|false)]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 3) {
        System.out.println("Usage: java twitter4j.examples.user.UpdateFriendship [screen name] [enable device notification(true|false)] [enable retweets(true|false)]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        Relationship relationship = twitter.updateFriendship(args[0], Boolean.parseBoolean(args[1]), Boolean.parseBoolean(args[2]));
        System.out.println("Successfully updated the friendship of [" + relationship.getTargetUserScreenName() + "].");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to update the friendship: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Relationship(twitter4j.Relationship) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Aggregations

TwitterFactory (twitter4j.TwitterFactory)68 Twitter (twitter4j.Twitter)60 TwitterException (twitter4j.TwitterException)55 ConfigurationBuilder (twitter4j.conf.ConfigurationBuilder)10 Status (twitter4j.Status)7 IDs (twitter4j.IDs)6 AccessToken (twitter4j.auth.AccessToken)5 SavedSearch (twitter4j.SavedSearch)4 RequestToken (twitter4j.auth.RequestToken)4 Configuration (twitter4j.conf.Configuration)4 File (java.io.File)3 User (twitter4j.User)3 UserList (twitter4j.UserList)3 Intent (android.content.Intent)2 AppSettings (com.klinker.android.twitter.settings.AppSettings)2 HttpServletRouter (h2weibo.HttpServletRouter)2 HashMap (java.util.HashMap)2 HttpSession (javax.servlet.http.HttpSession)2 AccessToken (twitter4j.http.AccessToken)2 AlarmManager (android.app.AlarmManager)1