Example usage for twitter4j Twitter createFriendship

List of usage examples for twitter4j Twitter createFriendship

Introduction

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

Prototype

User createFriendship(long userId, boolean follow) throws TwitterException;

Source Link

Document

Allows the authenticating users to follow the user specified in the ID parameter.
Returns the befriended user in the requested format when successful.

Usage

From source file:it.greenvulcano.gvesb.social.twitter.directcall.TwitterOperationEnableNotification.java

License:Open Source License

@Override
public void execute(SocialAdapterAccount account) throws SocialAdapterException {
    try {/*from  w  ww .  j  a va2  s. co m*/
        Twitter twitter = (Twitter) account.getProxyObject();
        try {
            long id = Long.parseLong(fromAccountId);
            user = twitter.createFriendship(id, true);
        } catch (NumberFormatException exc) {
            user = twitter.createFriendship(fromAccountId, true);
        }
    } catch (NumberFormatException exc) {
        logger.error("Call to TwitterOperationEnableNotification failed. Check fromAccountId[" + fromAccountId
                + "] format.", exc);
        throw new SocialAdapterException(
                "Call to TwitterOperationEnableNotification failed. Check fromAccountId[" + fromAccountId
                        + "] format.",
                exc);
    } catch (TwitterException exc) {
        logger.error("Call to TwitterOperationEnableNotification fromAccountId[" + fromAccountId + "] failed.",
                exc);
        throw new SocialAdapterException(
                "Call to TwitterOperationEnableNotification fromAccountId[" + fromAccountId + "] failed.", exc);
    }
}