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:org.soluvas.buzz.twitter.TwitterUser.java

License:Apache License

/**
 * Clones attributes from Twitter4j's {@link User}.
 * @param src// w  ww.  j  av  a2s  .  c  om
 */
public TwitterUser(User src, int revId, DateTime fetchTime) {
    super();
    this.revId = revId;
    this.fetchTime = fetchTime;
    id = src.getId();
    name = src.getName();
    screenName = src.getScreenName();
    location = src.getLocation();
    description = src.getDescription();
    contributorsEnabled = src.isContributorsEnabled();
    profileImageUrl = src.getProfileImageURL();
    biggerProfileImageUrl = src.getBiggerProfileImageURL();
    miniProfileImageUrl = src.getMiniProfileImageURL();
    originalProfileImageUrl = src.getOriginalProfileImageURL();
    profileImageUrlHttps = src.getProfileImageURLHttps();
    biggerProfileImageUrlHttps = src.getBiggerProfileImageURLHttps();
    miniProfileImageUrlHttps = src.getMiniProfileImageURLHttps();
    originalProfileImageUrlHttps = src.getOriginalProfileImageURLHttps();
    url = src.getURL();
    protectedState = src.isProtected();
    followersCount = src.getFollowersCount();
    status = src.getStatus();
    profileBackgroundColor = src.getProfileBackgroundColor();
    profileTextColor = src.getProfileTextColor();
    profileLinkColor = src.getProfileLinkColor();
    profileSidebarFillColor = src.getProfileSidebarFillColor();
    profileSidebarBorderColor = src.getProfileSidebarBorderColor();
    profileUseBackgroundImage = src.isProfileUseBackgroundImage();
    showAllInlineMedia = src.isShowAllInlineMedia();
    friendsCount = src.getFriendsCount();
    createdAt = new DateTime(src.getCreatedAt());
    favouritesCount = src.getFavouritesCount();
    utcOffset = src.getUtcOffset();
    timeZone = src.getTimeZone();
    profileBackgroundImageUrl = src.getProfileBackgroundImageURL();
    profileBackgroundImageUrlHttps = src.getProfileBackgroundImageUrlHttps();
    profileBannerUrl = src.getProfileBannerURL();
    profileBannerRetinaUrl = src.getProfileBannerRetinaURL();
    profileBannerIpadUrl = src.getProfileBannerIPadURL();
    profileBannerIpadRetinaUrl = src.getProfileBannerIPadRetinaURL();
    profileBannerMobileUrl = src.getProfileBannerMobileURL();
    profileBannerMobileRetinaUrl = src.getProfileBannerMobileRetinaURL();
    profileBackgroundTiled = src.isProfileBackgroundTiled();
    lang = src.getLang();
    statusesCount = src.getStatusesCount();
    geoEnabled = src.isGeoEnabled();
    verified = src.isVerified();
    translator = src.isTranslator();
    listedCount = src.getListedCount();
    followRequestSent = src.isFollowRequestSent();
}

From source file:org.springframework.social.showcase.twitter.connect.TwitterApiAdapter.java

License:Apache License

@Override
public UserProfile fetchUserProfile(Twitter api) {
    try {//from   w w w.j  a  va 2  s  .c  o  m
        User user = api.verifyCredentials();
        return new UserProfileBuilder().setName(user.getName()).setUsername(user.getScreenName()).build();
    } catch (TwitterException e) {
        return null;
    }
}

From source file:org.tweetalib.android.model.TwitterDirectMessage.java

License:Apache License

public TwitterDirectMessage(DirectMessage message, User otherUser) {
    mId = message.getId();//from  w  ww.jav  a2s  .  c  o  m
    mText = message.getText();
    mStatusFullMarkup = TwitterUtil.getStatusMarkup(mText, message.getMediaEntities(),
            message.getURLEntities());
    mTextSpanned = URLSpanNoUnderline
            .stripUnderlines(Html.fromHtml(mStatusFullMarkup.replace("\n", "<br/>") + " "));
    mCreatedAt = message.getCreatedAt();
    mOtherUserId = otherUser.getId();
    mRecipientUserId = message.getRecipientId();
    mOtherUserScreenName = otherUser.getScreenName();
    mOtherUserName = otherUser.getName();
    mOtherUserProfileImageOriginalUrl = otherUser.getOriginalProfileImageURL();
    mOtherUserProfileImageMiniUrl = otherUser.getMiniProfileImageURL();
    mOtherUserProfileImageNormalUrl = otherUser.getProfileImageURL();
    mOtherUserProfileImageBiggerUrl = otherUser.getBiggerProfileImageURL();
    TwitterUser sender = new TwitterUser(message.getSender());
    mSenderProfileImageOriginalUrl = sender.getProfileImageUrlOriginal();
    mSenderProfileImageMiniUrl = sender.getProfileImageUrlMini();
    mSenderProfileImageNormalUrl = sender.getProfileImageUrlNormal();
    mSenderProfileImageBiggerUrl = sender.getProfileImageUrlBigger();
    mMessageType = mRecipientUserId == mOtherUserId ? MessageType.SENT : MessageType.RECEIVED;
}

From source file:org.tweetalib.android.model.TwitterStatus.java

License:Apache License

public TwitterStatus(Status status) {
    User statusUser = status.getUser();

    mCreatedAt = status.getCreatedAt();/*w  ww. j  a  v  a 2s  .  c  om*/
    mId = status.getId();
    if (status.getInReplyToStatusId() != -1) {
        mInReplyToStatusId = status.getInReplyToStatusId();
    }
    if (status.getInReplyToUserId() != -1) {
        mInReplyToUserId = status.getInReplyToUserId();
    }
    mInReplyToUserScreenName = status.getInReplyToScreenName();
    mIsFavorited = status.isFavorited();
    mIsRetweet = status.isRetweet();
    mIsRetweetedByMe = status.isRetweetedByMe();

    mSource = TwitterUtil.stripMarkup(status.getSource());

    if (statusUser != null) {
        mUserId = statusUser.getId();
        mUserName = statusUser.getName();
        mUserScreenName = statusUser.getScreenName();
    }

    mMediaEntity = TwitterMediaEntity.createMediaEntity(status);

    boolean useDefaultAuthor = true;
    if (mIsRetweet) {
        if (status.getRetweetedStatus() != null && status.getRetweetedStatus().getUser() != null) {
            SetProfileImagesFromUser(new TwitterUser(status.getRetweetedStatus().getUser()));
        }
        mOriginalRetweetId = status.getRetweetedStatus().getId();

        // You'd think this check wasn't necessary, but apparently not...
        UserMentionEntity[] userMentions = status.getUserMentionEntities();
        if (userMentions != null && userMentions.length > 0) {
            useDefaultAuthor = false;
            UserMentionEntity authorMentionEntity = status.getUserMentionEntities()[0];
            mAuthorId = authorMentionEntity.getId();
            mAuthorName = authorMentionEntity.getName();
            mAuthorScreenName = authorMentionEntity.getScreenName();

            Status retweetedStatus = status.getRetweetedStatus();
            mStatus = retweetedStatus.getText();
            setStatusMarkup(retweetedStatus);
            mRetweetCount = retweetedStatus.getRetweetCount();
            mUserMentions = TwitterUtil.getUserMentions(retweetedStatus.getUserMentionEntities());
            mIsRetweetedByMe = retweetedStatus.isRetweetedByMe();
        }
    } else {
        if (statusUser != null) {
            SetProfileImagesFromUser(new TwitterUser(statusUser));
        }
    }

    if (useDefaultAuthor) {
        if (statusUser != null) {
            mAuthorId = statusUser.getId();
        }
        mStatus = status.getText();
        setStatusMarkup(status);
        mRetweetCount = status.getRetweetCount();
        mUserMentions = TwitterUtil.getUserMentions(status.getUserMentionEntities());
    }

    /*
     * if (status.getId() == 171546910249852928L) { mStatus =
     * "<a href=\"http://a.com\">@chrismlacy</a> You've been working on Tweet Lanes for ages. Is it done yet?"
     * ; mStatusMarkup =
     * "<a href=\"http://a.com\">@chrismlacy</a> You've been working on Tweet Lanes for ages. Is it done yet?"
     * ; mAuthorScreenName = "emmarclarke"; mStatusMarkup = mStatus; } else
     * if (status.getId() == 171444098698457089L) { mStatus =
     * "<a href=\"http://a.com\">@chrismlacy</a> How's that app of yours coming along?"
     * ; mStatusMarkup =
     * "<a href=\"http://a.com\">@chrismlacy</a> How's that app of yours coming along?"
     * ; mStatusMarkup = mStatus; }
     */
}

From source file:org.tweetalib.android.model.TwitterUser.java

License:Apache License

public TwitterUser(User user) {
    mId = user.getId();// ww  w .  j a v  a 2 s. c o  m
    mScreenName = user.getScreenName();
    mName = user.getName();
    mDescription = user.getDescription();
    ArrayList<URLEntity> urlEntityArrayList = new ArrayList<URLEntity>();
    if (user.getDescriptionURLEntities() != null) {
        urlEntityArrayList = new ArrayList<URLEntity>(Arrays.asList(user.getDescriptionURLEntities()));
    }

    if (user.getURL() != null) {
        mUrl = user.getURL();
        urlEntityArrayList.add(user.getURLEntity());
    }

    mUrlEntities = urlEntityArrayList.toArray(new URLEntity[urlEntityArrayList.size()]);

    if (user.getLocation() != null && !user.getLocation().equals("")) {
        mLocation = user.getLocation();
    }

    if (user.getOriginalProfileImageURLHttps() != null) {
        mProfileImageUrlOriginal = user.getOriginalProfileImageURLHttps();
    }

    if (user.getBiggerProfileImageURLHttps() != null) {
        mProfileImageUrlBigger = user.getBiggerProfileImageURLHttps();
    }

    if (user.getProfileImageURLHttps() != null) {
        mProfileImageUrlNormal = user.getProfileImageURLHttps();
    }

    if (user.getMiniProfileImageURLHttps() != null) {
        mProfileImageUrlMini = user.getMiniProfileImageURLHttps();
    }

    mStatusesCount = user.getStatusesCount();
    mFriendsCount = user.getFriendsCount();
    mFollowersCount = user.getFollowersCount();
    mFavoritesCount = user.getFavouritesCount();
    mListedCount = user.getListedCount();
    mVerified = user.isVerified();
    mProtected = user.isProtected();
    mSocialNetType = SocialNetConstant.Type.Twitter;
}

From source file:org.wandora.application.tools.extractors.twitter.AbstractTwitterExtractor.java

License:Open Source License

public Topic reifyTwitterUser(User user, TopicMap tm) {
    String userName = user.getName();
    String screenName = user.getScreenName();
    String userURL = user.getURL();
    long uid = user.getId();

    String si = TWITTER_USER_SI_BODY + urlEncode(screenName);

    Topic twitterUserTopic = null;//from w w w. j  a  v  a  2  s. c o  m
    try {
        twitterUserTopic = tm.getTopic(si);
        if (twitterUserTopic == null) {
            twitterUserTopic = tm.createTopic();
            twitterUserTopic.addSubjectIdentifier(new Locator(si));
            twitterUserTopic.setBaseName(screenName + " (" + uid + ")");
            twitterUserTopic.setDisplayName(DEFAULT_LANG, userName);
            twitterUserTopic.addType(getTwitterUserType(tm));
        }
    } catch (Exception e) {
        log(e);
    }
    return twitterUserTopic;
}

From source file:org.wso2.carbon.identity.authenticator.twitter.TwitterAuthenticator.java

License:Open Source License

public void buildClaims(User user, AuthenticationContext context) {
    AuthenticatedUser authenticatedUserObj;
    authenticatedUserObj = AuthenticatedUser
            .createFederateAuthenticatedUserFromSubjectIdentifier(user.getId() + "");
    authenticatedUserObj.setAuthenticatedSubjectIdentifier(user.getId() + "");

    Map<ClaimMapping, String> claims = new HashMap<ClaimMapping, String>();
    claims.put(ClaimMapping.build(TwitterAuthenticatorConstants.TWITTER_CLAIM_NAME,
            TwitterAuthenticatorConstants.TWITTER_CLAIM_NAME, (String) null, false), user.getName());
    claims.put(ClaimMapping.build(TwitterAuthenticatorConstants.TWITTER_CLAIM_EMAIL,
            TwitterAuthenticatorConstants.TWITTER_CLAIM_EMAIL, (String) null, false), user.getEmail());
    authenticatedUserObj.setUserAttributes(claims);
    context.setSubject(authenticatedUserObj);
}

From source file:org.xmlsh.twitter.util.TwitterWriter.java

License:BSD License

private void write(String localName, User user) throws XMLStreamException {
    startElement("user");
    attribute("created-at", user.getCreatedAt());
    attribute("description", user.getDescription());
    attribute("favorites-count", user.getFavouritesCount());
    user.getFollowersCount();/*from   ww  w . j a  va2 s. c  o  m*/
    user.getFriendsCount();
    attribute("id", sanitizeID(user.getId()));
    attribute("lang", user.getLang());
    user.getListedCount();

    attribute("name", sanitizeUser(user.getName()));
    user.getProfileBackgroundColor();
    user.getProfileBackgroundImageUrl();
    user.getProfileBackgroundImageUrlHttps();
    user.getProfileImageURL();
    user.getProfileImageUrlHttps();
    user.getProfileLinkColor();
    user.getProfileSidebarBorderColor();
    user.getProfileTextColor();
    user.getRateLimitStatus();
    attribute("screen-name", sanitizeUser(user.getScreenName()));

    user.getStatusesCount();
    user.getTimeZone();
    user.getURL();
    user.getUtcOffset();
    write("location", user.getLocation());
    write("user-status", user.getStatus());
    endElement();

}

From source file:peoplesearch.FindFriendsAndFollowers.java

public void GetFollowersIDs() {
    try {/*w  ww  . ja  v  a2  s. co m*/
        // I need to pass the Person name and the TwitterID.
        //String targetname="Philip Bergkvist";
        Twitter twitter = new TwitterFactory().getInstance();
        long cursor = -1;
        IDs ids;

        ResponseList<User> users1 = null;
        ResponseList<User> users2 = null;
        System.out.println("Listing followers's ids.");

        GraphManager mgr = EmbeddedGraphManager.getInstance();

        mgr.init(new File("/usr/local/Cellar/neo4j/2.1.7/libexec/data/forlang1.db"));
        //mgr.addTwitterAccount(new TwitterAccountImpl(new Date(), "I am Studying", 13, 82, true,"Aalborg", "Philiptwoshoes", 2730631792L));
        List<TwitterAccount> twitteraccountslist;
        twitteraccountslist = null;
        twitteraccountslist = mgr.listTwitterAccounts();
        System.out.println("the number of twitter account in the neo4J DB is" + twitteraccountslist.size());
        for (TwitterAccount Twit : twitteraccountslist) {

            do {
                TwitterLimitWait tlw = new TwitterLimitWait();
                tlw.CheckLimit();

                if (0 < twitteraccountslist.size()) {
                    ids = twitter.getFollowersIDs(Twit.getScreenName(), cursor); //.getFollowersIDs(pep[0], cursor);
                    //ids = twitter.getFollowersIDs("Philiptwoshoes", cursor); //.getFollowersIDs(pep[0], cursor);
                    tlw.CheckLimit();
                    users1 = twitter.getFollowersList(Twit.getScreenName(), cursor);
                    tlw.CheckLimit();
                    users2 = twitter.getFriendsList(Twit.getScreenName(), cursor);

                } else {
                    tlw.CheckLimit();
                    ids = twitter.getFollowersIDs(cursor);

                }

                for (User user : users1) {
                    tlw.CheckLimit();
                    System.out.println("the follower called " + user.getName() + " with twitter handler "
                            + user.getScreenName());
                    String username = user.getName();
                    //mgr.addPerson(new PersonImpl(username));
                    Date Creation = user.getCreatedAt();
                    tlw.CheckLimit();
                    String descript = user.getDescription();
                    boolean empty1 = user.getDescription().isEmpty();
                    if (empty1 == true) {
                        descript = " ";
                    }
                    tlw.CheckLimit();
                    int followers = user.getFollowersCount();
                    tlw.CheckLimit();
                    int following = user.getFriendsCount();
                    boolean geo = user.isGeoEnabled();
                    String loc = user.getLocation();
                    boolean empty2 = user.getLocation().isEmpty();
                    if (empty2 == true) {
                        loc = " ";
                    }
                    String screenname = user.getScreenName();
                    boolean empty3 = user.getScreenName().isEmpty();
                    if (empty3 == true) {
                        screenname = " ";
                    }
                    tlw.CheckLimit();
                    long twitID = user.getId();

                    mgr.linkPersonToTwitterAccount(new PersonImpl(username), new TwitterAccountImpl(Creation,
                            descript, followers, following, geo, loc, screenname, twitID));
                    mgr.linkTwitterAccounts(new TwitterAccountImpl(Creation, descript, followers, following,
                            geo, loc, screenname, twitID), Twit);
                }

                System.out.println("The total number of followers is: " + users1.size());
                // the same procedure for the Following
                for (User user : users2) {
                    tlw.CheckLimit();
                    System.out.println("the following called " + user.getName() + " with twitter handler "
                            + user.getScreenName());
                    String username1 = user.getName();
                    //mgr.addPerson(new PersonImpl(username1));
                    Date Creation = user.getCreatedAt();
                    String descript = user.getDescription();
                    boolean empty1 = user.getDescription().isEmpty();
                    if (empty1 == true) {
                        descript = " ";
                    }
                    int followers = user.getFollowersCount();
                    int following = user.getFriendsCount();
                    boolean geo = user.isGeoEnabled();
                    String loc = user.getLocation();
                    boolean empty2 = user.getLocation().isEmpty();
                    if (empty2 == true) {
                        loc = " ";
                    }
                    String screenname = user.getScreenName();
                    tlw.CheckLimit();
                    boolean empty3 = user.getScreenName().isEmpty();
                    if (empty3 == true) {
                        screenname = " ";
                    }
                    tlw.CheckLimit();
                    long twitID = user.getId();
                    //mgr.addTwitterAccount(new TwitterAccountImpl(Creation,descript,followers,following,geo,loc,screenname,twitID));
                    mgr.linkPersonToTwitterAccount(new PersonImpl(username1), new TwitterAccountImpl(Creation,
                            descript, followers, following, geo, loc, screenname, twitID));
                    mgr.linkTwitterAccounts(Twit, new TwitterAccountImpl(Creation, descript, followers,
                            following, geo, loc, screenname, twitID));
                }
                System.out.println("The total number of friend is: " + users2.size());

                //}
            } while ((cursor = ids.getNextCursor()) != 0);

        }
        mgr.destroy(); // I have to check that the second iteration works fine, because i could not test that.
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get followers' ids: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:Servlet.CallbackServlet.java

License:Apache License

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
 *
 * @param request servlet request//from   w ww . j  av a 2  s  .  c  o m
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");

    Twitter twitter = (Twitter) request.getSession().getAttribute("twitter");
    RequestToken requestToken = (RequestToken) request.getSession().getAttribute("requestToken");
    String verifier = request.getParameter("oauth_verifier");

    try {
        twitter.getOAuthAccessToken(requestToken, verifier);
        request.getSession().removeAttribute("requestToken");

        String twitterIDString = Long.toString(twitter.getId());
        twitter4j.User user = twitter.showUser(twitter.getId());

        Model.User loggedUser = DBAdmin.getTwitterUser(twitterIDString);

        if (loggedUser == null) {
            String username = user.getName().replaceAll(" ", "");

            if (DBAdmin.isUsernameTaken(username)) {
                int i = 1;
                while (DBAdmin.isUsernameTaken(username + i)) {
                    i++;
                }
                username += i;
            }

            DBAdmin.registerTwitter(twitterIDString, username, "null", "", "player", user.getName(),
                    "unaffliated");
            DirectoryAdmin.prepNewUserDirectory(request, username);

            loggedUser = DBAdmin.getTwitterUser(twitterIDString);
        }

        request.getSession().setAttribute("loggedUser", loggedUser);
    } catch (IllegalStateException | TwitterException ex) {
        throw new ServletException(ex);
    }

    response.sendRedirect("main");
}