Example usage for twitter4j AsyncTwitter sendDirectMessage

List of usage examples for twitter4j AsyncTwitter sendDirectMessage

Introduction

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

Prototype

void sendDirectMessage(long userId, String text);

Source Link

Document

Sends a new direct message to the specified user from the authenticating user.

Usage

From source file:com.marpies.ane.twitter.functions.SendDirectMessageFunction.java

License:Apache License

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

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

    AsyncTwitter twitter = TwitterAPI.getAsyncInstance(TwitterAPI.getAccessToken());
    twitter.addListener(this);
    if (screenName != null) {
        twitter.sendDirectMessage(screenName, message);
    } else {//from w ww .  ja  v a2  s. c  o m
        twitter.sendDirectMessage(userID, message);
    }

    return null;
}