Example usage for twitter4j AsyncTwitter getFavorites

List of usage examples for twitter4j AsyncTwitter getFavorites

Introduction

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

Prototype

void getFavorites(long userId, Paging paging);

Source Link

Document

Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.

Usage

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

License:Apache License

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

    int count = FREObjectUtils.getInt(args[0]);
    long sinceID = (args[1] == null) ? -1 : Long.valueOf(FREObjectUtils.getString(args[1]));
    long maxID = (args[2] == null) ? -1 : Long.valueOf(FREObjectUtils.getString(args[2]));
    long userID = FREObjectUtils.getDouble(args[3]).longValue();
    String screenName = (args[4] == null) ? null : FREObjectUtils.getString(args[4]);
    mCallbackID = FREObjectUtils.getInt(args[5]);

    AsyncTwitter twitter = TwitterAPI.getAsyncInstance(TwitterAPI.getAccessToken());
    twitter.addListener(this);

    /* If user ID was not provided then use the one of currently logged in user */
    if (userID < 0) {
        userID = TwitterAPI.getLoggedInUser().getId();
    }/*from  ww w  . j a  v  a2  s  . co m*/

    Paging paging = getPaging(count, sinceID, maxID);
    if (paging != null) {
        if (screenName != null) {
            twitter.getFavorites(screenName, paging);
        } else {
            twitter.getFavorites(userID, paging);
        }
    } else {
        if (screenName != null) {
            twitter.getFavorites(screenName);
        } else {
            twitter.getFavorites(userID);
        }
    }

    return null;
}