Search in sources :

Example 21 with TwitterException

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);
    }
}
Also used : Status(twitter4j.Status) TwitterException(twitter4j.TwitterException)

Example 22 with TwitterException

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);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) UserList(twitter4j.UserList) TwitterException(twitter4j.TwitterException)

Example 23 with TwitterException

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);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 24 with TwitterException

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);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) UserList(twitter4j.UserList) TwitterException(twitter4j.TwitterException)

Example 25 with TwitterException

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);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) UserList(twitter4j.UserList) TwitterException(twitter4j.TwitterException)

Aggregations

TwitterException (twitter4j.TwitterException)88 Twitter (twitter4j.Twitter)69 TwitterFactory (twitter4j.TwitterFactory)54 Status (twitter4j.Status)19 Intent (android.content.Intent)9 User (twitter4j.User)8 ArrayList (java.util.ArrayList)7 File (java.io.File)6 DirectMessage (twitter4j.DirectMessage)6 IDs (twitter4j.IDs)6 Paging (twitter4j.Paging)6 Context (android.content.Context)4 AppSettings (com.klinker.android.twitter.settings.AppSettings)4 Date (java.util.Date)4 SavedSearch (twitter4j.SavedSearch)4 AccessToken (twitter4j.auth.AccessToken)4 MentionsDataSource (com.klinker.android.twitter.data.sq_lite.MentionsDataSource)3 IOException (java.io.IOException)3 UserList (twitter4j.UserList)3 RequestToken (twitter4j.auth.RequestToken)3