Search in sources :

Example 1 with Relationship

use of twitter4j.Relationship in project twitter4j by yusuke.

the class ShowFriendship method main.

/**
     * Usage: java twitter4j.examples.friendship.ShowFriendship  [source screen name] [target screen name]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 2) {
        System.out.println("Usage: java twitter4j.examples.friendship.ShowFriendship [source screen name] [target screen name]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        Relationship relationship = twitter.showFriendship(args[0], args[1]);
        System.out.println("isSourceBlockingTarget: " + relationship.isSourceBlockingTarget());
        System.out.println("isSourceFollowedByTarget: " + relationship.isSourceFollowedByTarget());
        System.out.println("isSourceFollowingByTarget: " + relationship.isSourceFollowingTarget());
        System.out.println("isSourceNotificationsEnabled: " + relationship.isSourceNotificationsEnabled());
        System.out.println("canSourceDm: " + relationship.canSourceDm());
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to show friendship: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Relationship(twitter4j.Relationship) Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException)

Example 2 with Relationship

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

Relationship (twitter4j.Relationship)2 Twitter (twitter4j.Twitter)2 TwitterException (twitter4j.TwitterException)2 TwitterFactory (twitter4j.TwitterFactory)2