List of usage examples for twitter4j AsyncTwitter showUser
void showUser(long userId);
From source file:com.marpies.ane.twitter.functions.GetLoggedInUserFunction.java
License:Apache License
@Override public FREObject call(FREContext context, FREObject[] args) { super.call(context, args); mCallbackID = FREObjectUtils.getInt(args[0]); User user = TwitterAPI.getLoggedInUser(); /* Return cached object */ if (user != null) { try {/*from www .j av a 2s . c o m*/ dispatchUser(user); } catch (Exception e) { e.printStackTrace(); AIR.dispatchEvent(AIRTwitterEvent.USER_QUERY_ERROR, StringUtils.getEventErrorJSON(mCallbackID, e.getMessage())); } } /* Request user info */ else if (TwitterAPI.hasAccessTokens()) { AccessToken accessToken = TwitterAPI.getAccessToken(); AsyncTwitter twitter = TwitterAPI.getAsyncInstance(accessToken); twitter.addListener(this); twitter.showUser(accessToken.getUserId()); } /* User not logged in, error */ else { AIR.dispatchEvent(AIRTwitterEvent.USER_QUERY_ERROR, StringUtils.getEventErrorJSON(mCallbackID, "User is not logged in.")); } return null; }
From source file:com.marpies.ane.twitter.functions.GetUserFunction.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]); mCallbackID = FREObjectUtils.getInt(args[2]); AccessToken accessToken = TwitterAPI.getAccessToken(); AsyncTwitter twitter = TwitterAPI.getAsyncInstance(accessToken); twitter.addListener(this); if (screenName != null) { AIR.log("Getting user info for " + screenName); twitter.showUser(screenName); } else {//from ww w . ja v a2 s .com AIR.log("Getting user info for userID: " + userID); twitter.showUser(userID); } return null; }