Search in sources :

Example 71 with TwitterException

use of twitter4j.TwitterException 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 72 with TwitterException

use of twitter4j.TwitterException 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)

Example 73 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class GetGeoDetails method main.

/**
     * Usage: java twitter4j.examples.geo.GetGeoDetails [place id]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.geo.GetGeoDetails [place id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        Place place = twitter.getGeoDetails(args[0]);
        System.out.println("name: " + place.getName());
        System.out.println("country: " + place.getCountry());
        System.out.println("country code: " + place.getCountryCode());
        System.out.println("full name: " + place.getFullName());
        System.out.println("id: " + place.getId());
        System.out.println("place type: " + place.getPlaceType());
        System.out.println("street address: " + place.getStreetAddress());
        Place[] containedWithinArray = place.getContainedWithIn();
        if (containedWithinArray != null && containedWithinArray.length != 0) {
            System.out.println("  contained within:");
            for (Place containedWithinPlace : containedWithinArray) {
                System.out.println("  id: " + containedWithinPlace.getId() + " name: " + containedWithinPlace.getFullName());
            }
        }
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to retrieve geo details: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException) Place(twitter4j.Place)

Example 74 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class GetPrivacyPolicy method main.

/**
     * Usage: java twitter4j.examples.help.GetPrivacyPolicy
     *
     * @param args String[]
     */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        System.out.println(twitter.getPrivacyPolicy());
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get privacy policy: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 75 with TwitterException

use of twitter4j.TwitterException in project twitter4j by yusuke.

the class GetTermsOfService method main.

/**
     * Usage: java twitter4j.examples.help.GetTermsOfService
     *
     * @param args String[]
     */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        System.out.println(twitter.getTermsOfService());
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get tems of service: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Aggregations

TwitterException (twitter4j.TwitterException)96 Twitter (twitter4j.Twitter)69 TwitterFactory (twitter4j.TwitterFactory)54 Status (twitter4j.Status)21 User (twitter4j.User)12 Intent (android.content.Intent)11 ArrayList (java.util.ArrayList)9 File (java.io.File)6 IDs (twitter4j.IDs)6 Context (android.content.Context)5 Date (java.util.Date)4 DirectMessage (twitter4j.DirectMessage)4 Paging (twitter4j.Paging)4 AccessToken (twitter4j.auth.AccessToken)4 Activity (android.app.Activity)3 SharedPreferences (android.content.SharedPreferences)3 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)3 View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3