Example usage for twitter4j Twitter updateFriendship

List of usage examples for twitter4j Twitter updateFriendship

Introduction

In this page you can find the example usage for twitter4j Twitter updateFriendship.

Prototype

Relationship updateFriendship(long userId, boolean enableDeviceNotification, boolean retweets)
        throws TwitterException;

Source Link

Document

Allows you to enable or disable retweets and device notifications from the specified user.

Usage

From source file:twitter4j.examples.friendship.UpdateFriendship.java

License:Apache License

/**
 * Usage: java twitter4j.examples.user.UpdateFriendship [screen name] [enable device notification(true|false)] [enable retweets(true|false)]
 *
 * @param args message//from w  w  w .  j a va 2 s.  c  o  m
 */
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);
    }
}