Example usage for twitter4j AsyncTwitter createFriendship

List of usage examples for twitter4j AsyncTwitter createFriendship

Introduction

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

Prototype

void createFriendship(long userId, boolean follow);

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:com.marpies.ane.twitter.functions.FollowUserFunction.java

License:Apache License

@Override
public FREObject call(FREContext context, FREObject[] args) {
    super.call(context, args);

    long userID = FREObjectUtils.getDouble(args[0]).longValue();
    String screenName = (args[1] == null) ? null : FREObjectUtils.getString(args[1]);
    boolean enableNotifications = FREObjectUtils.getBoolean(args[2]);
    mCallbackID = FREObjectUtils.getInt(args[3]);

    AsyncTwitter twitter = TwitterAPI.getAsyncInstance(TwitterAPI.getAccessToken());
    twitter.addListener(this);
    if (screenName != null) {
        if (enableNotifications) {
            twitter.createFriendship(screenName, true);
        } else {//from w  ww  .  j  ava2 s .  c o m
            twitter.createFriendship(screenName);
        }
    } else {
        if (enableNotifications) {
            twitter.createFriendship(userID, true);
        } else {
            twitter.createFriendship(userID);
        }
    }

    return null;
}