Example usage for twitter4j User getName

List of usage examples for twitter4j User getName

Introduction

In this page you can find the example usage for twitter4j User getName.

Prototype

String getName();

Source Link

Document

Returns the name of the user

Usage

From source file:aic2013.common.entities.TwitterUser.java

public TwitterUser(User user) {
    id = user.getId();//from   w  ww.  j  a v  a  2 s .c o  m
    name = user.getName();
    screenName = user.getScreenName();
    lang = user.getLang();
    followersCount = user.getFollowersCount();
    statusesCount = user.getStatusesCount();
    friendsCount = user.getFriendsCount();
    favouritesCount = user.getFavouritesCount();
    listedCount = user.getListedCount();
}

From source file:aic2013.extractor.entities.TwitterUser.java

public TwitterUser(User user) {
    id = user.getId();/*from   w w  w .  j  ava2 s  . c  o m*/
    name = user.getName();
    screenName = user.getScreenName();
    language = user.getLang();
    followersCount = user.getFollowersCount();
    statusesCount = user.getStatusesCount();
    friendsCount = user.getFriendsCount();
    favouritesCount = user.getFavouritesCount();
    listedCount = user.getListedCount();
}

From source file:au.net.moon.tUtils.TUser.java

License:Open Source License

/**
 * Create a user object from a twitter4j user.
 * /*  www  . j av  a2 s  . c  o  m*/
 * @param twitterUser
 *            a twitter4j user object
 */
public TUser(twitter4j.User twitterUser) {
    id = twitterUser.getId();
    name = twitterUser.getName();
    screenName = twitterUser.getScreenName();
    location = twitterUser.getLocation();
    description = twitterUser.getDescription();
    if (twitterUser.getProfileImageURL() != null) {
        profileImageUrl = twitterUser.getProfileImageURL().toString();
    } else {
        profileImageUrl = "";
    }
    if (twitterUser.getURL() != null) {
        url = twitterUser.getURL().toString();
    } else {
        url = "";
    }
    createdAt = twitterUser.getCreatedAt();
    isProtected = twitterUser.isProtected();
    followersCount = twitterUser.getFollowersCount();
    // Not interested in users latest tweet, so just leave blank
    status = "";
    profileBackgroundColor = twitterUser.getProfileBackgroundColor();
    profileTextColor = twitterUser.getProfileTextColor();
    profileLinkColor = twitterUser.getProfileLinkColor();
    profileSidebarFillColor = twitterUser.getProfileSidebarFillColor();
    profileSidebarBorderColor = twitterUser.getProfileSidebarBorderColor();
    friendsCount = twitterUser.getFriendsCount();
    favouritesCount = twitterUser.getFavouritesCount();
    utcOffset = twitterUser.getUtcOffset();
    timeZone = twitterUser.getTimeZone();
    if (twitterUser.getOriginalProfileImageURL() != null) {
        profileBackgroundImageUrl = twitterUser.getOriginalProfileImageURL().toString();
    } else {
        profileBackgroundImageUrl = "";
    }
    isProfileBackgroundTiled = twitterUser.isProfileBackgroundTiled();
    statusesCount = twitterUser.getStatusesCount();
    isGeoEnabled = twitterUser.isGeoEnabled();
    isVerified = twitterUser.isVerified();
    // isFollowing = twitterUser.isFollowing();

    isContributorsEnabled = twitterUser.isContributorsEnabled();
    isProfileUseBackgroundImage = twitterUser.isProfileUseBackgroundImage();
    isShowAllInLineMedia = twitterUser.isShowAllInlineMedia();
    lang = twitterUser.getLang();
    isTranslator = twitterUser.isTranslator();
    listedCount = twitterUser.getListedCount();
    isFollowRequestSent = twitterUser.isFollowRequestSent();

    // TODO: Need to pass in the searchAPI id if I have it.
    searchAPI_userID = "";
}

From source file:br.com.porcelli.hornetq.integration.twitter.support.TweetMessageConverterSupport.java

License:Apache License

private static void buildUserData(final String prefix, final User user, ServerMessage msg) {
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_ID, read(user.getId()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_NAME, read(user.getName()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_SCREEN_NAME, read(user.getScreenName()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_LOCATION, read(user.getLocation()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_DESCRIPTION, read(user.getDescription()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_PROFILE_IMAGE_URL,
            read(user.getProfileImageURL()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_URL, read(user.getURL()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_LANG, read(user.getLang()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_PROTECTED, read(user.isProtected()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_FOLLOWERS_COUNT, read(user.getFollowersCount()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_FRIENDS_COUNT, read(user.getFriendsCount()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_CREATED_AT, read(user.getCreatedAt()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_FAVOURITES_COUNT, read(user.getFavouritesCount()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_UTC_OFFSET, read(user.getUtcOffset()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_TIME_ZONE, read(user.getTimeZone()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_STATUSES_COUNT, read(user.getStatusesCount()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_VERIFIED, read(user.isVerified()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_CONTRIBUTORS_ENABLED,
            read(user.isContributorsEnabled()));
    msg.putStringProperty(prefix + TwitterConstants.KEY_USER_GEO_ENABLED, read(user.isGeoEnabled()));
}

From source file:com.ahuralab.mozaic.db.Message.java

License:Open Source License

public static Message create(Status status) {

    User user = status.getUser();

    return new Message(status.getText(), status.getCreatedAt(), status.getRetweetCount(), user.getId(),
            user.getName(), user.getScreenName(), user.getLocation(), user.getDescription(),
            user.getProfileImageURL(), status.getId(), 0, 0, user.getFollowersCount(), user.getStatusesCount());
}

From source file:com.amandine.twitterpostforcoucou.Tweet.java

public void getFollowers(String username) {
    Twitter twitterHandle = this.getTwitter();
    long cursor = -1;
    PagableResponseList<User> followers = null;
    //do {//  w ww  . ja  va  2 s. c  o  m
    try {
        followers = twitterHandle.getFollowersList(URLEncoder.encode(username, "UTF-8"), cursor);
    } catch (TwitterException ex) {
        //ex.printStackTrace();
        logger.log(Level.SEVERE, "Cannot get followers", ex.getMessage());
        return;
    } catch (UnsupportedEncodingException ex) {
        Logger.getLogger(Tweet.class.getName()).log(Level.SEVERE, null, ex);
    }
    for (User follower : followers) {
        // TODO: Collect top 10 followers here
        System.out.println(follower.getName() + " has " + follower.getFollowersCount() + " follower(s)");
    }
    //} while ((cursor = followers.getNextCursor()) != 0);
}

From source file:com.anshul.HomeServlet.java

License:Open Source License

private void statusCheck(Twitter twitter, HttpServletRequest req, HttpServletResponse resp)
        throws IOException, TwitterException {
    User user = twitter.verifyCredentials();

    String username = user.getName();
    String latestTweet = user.getStatus().getText();
    TweetWrapper tweetWrapper = TweetWrapper.feel(latestTweet);
    String emotion = tweetWrapper.getStrongestEmotion();

    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Query query = new Query("Station");
    query.setFilter(FilterOperator.EQUAL.of("mood", emotion));
    List<Entity> stations = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(1));
    Entity station = stations.get(0);

    req.getSession().setAttribute("user", username);
    req.getSession().setAttribute("userId", user.getId());
    req.getSession().setAttribute("latestTweet", latestTweet);
    req.getSession().setAttribute("emotion", emotion);
    req.getSession().setAttribute("stationName", station.getProperty("name"));
    req.getSession().setAttribute("url", station.getProperty("url"));
    req.getSession().setAttribute("profileImage", user.getBiggerProfileImageURL());
    req.removeAttribute("oauth_token");
    req.removeAttribute("oauth_verifier");
    resp.sendRedirect("login.jsp");
}

From source file:com.codegoogle.twitterandroid.TwitterApp.java

License:Apache License

public void processToken(String callbackUrl) {
    progressDialog.setMessage("Finalizing ...");
    progressDialog.show();// w  w  w. j  ava2  s  . co  m

    final String verifier = getVerifier(callbackUrl);

    new Thread() {
        @Override
        public void run() {
            int what = 1;

            try {
                httpOauthprovider.retrieveAccessToken(httpOauthConsumer, verifier);

                accessToken = new AccessToken(httpOauthConsumer.getToken(), httpOauthConsumer.getTokenSecret());

                configureToken();

                User user = twitter.verifyCredentials();

                session.storeAccessToken(accessToken, user.getName());

                what = 0;
            } catch (Exception e) {
                e.printStackTrace();
            }

            handler.sendMessage(handler.obtainMessage(what, 2, 0));
        }
    }.start();
}

From source file:com.daemon.database.Transactor.java

License:Open Source License

/**
 * Creates an error message with user information for further analysis.
 * @param user The user whose information is to be represented.
 * @return The error message.//from w  w  w.ja va2 s  .  c  om
 */
private String getUserErrorString(User user) {
    StringBuffer sb = new StringBuffer();

    sb.append("User information:\n");
    sb.append("  id: " + user.getId() + "\n");
    sb.append("  screen name: " + user.getScreenName() + "\n");
    sb.append("  name: " + user.getName() + "\n");
    sb.append("  description: " + user.getDescription() + "\n");
    sb.append("    length: " + user.getDescription().length() + "\n");
    sb.append("   elength: " + StringUtil.escapeNonAscii(user.getDescription()).length() + "\n");
    sb.append("  language: " + user.getLang() + "\n");
    sb.append("  location: " + user.getLocation());

    return sb.toString();
}

From source file:com.daemon.database.Transactor.java

License:Open Source License

/**
 * Adds only the given User to the SQL.Batch which will be saved
 *  in the DB by savedAllTweetsTransactionsafe  
 * /*from   w ww  . j  a  v a  2  s. co  m*/
 * @param user The user to be saved.
 * @throws SQLException
 */
private void saveUser(User user) throws SQLException {
    prepStatementUser.setLong(1, user.getId());
    prepStatementUser.setString(2, user.getName());
    prepStatementUser.setString(3, user.getScreenName());
    prepStatementUser.setString(4, user.getProfileImageURL());
    prepStatementUser.setTimestamp(5, new java.sql.Timestamp(user.getCreatedAt().getTime()));
    prepStatementUser.setString(6, user.getLocation());
    prepStatementUser.setString(7, user.getURL());
    prepStatementUser.setString(8, user.getLang());
    prepStatementUser.setInt(9, user.getFollowersCount());
    prepStatementUser.setBoolean(10, user.isVerified());
    prepStatementUser.setString(11, user.getTimeZone());
    prepStatementUser.setString(12, user.getDescription());
    prepStatementUser.setInt(13, user.getStatusesCount());
    prepStatementUser.setInt(14, user.getFriendsCount());

    prepStatementUser.addBatch();
}