List of usage examples for twitter4j User getScreenName
String getScreenName();
From source file:org.sociotech.communitymashup.source.twitter.TwitterSourceService.java
License:Open Source License
/** * Looks up the person for this twitter user in the given dataSet and * returns it. If it does not already exist, the person will be created and * returned.// ww w . j a v a2 s .c o m * * @param user * @return */ private Person createPersonFromTwitterUser(User user) { if (user == null) { return null; } Person person = getPersonForTwitterUser(user); String personIdent = createPersonIdentForTwitterUser(user); if (person == null) { // not previously created person = factory.createPerson(); // set name person.setName(user.getName()); // and add the person to the data set person = (Person) this.add(person, personIdent); } if (person == null) { // person could not be created return null; } // tag person person.metaTag(TwitterTags.TWITTER); // add web account String screenName = user.getScreenName(); if (screenName != null && !screenName.equals("")) { // TODO check for existing web account WebAccount webAccount = factory.createWebAccount(); webAccount.setUsername(screenName); webAccount.setCreated(user.getCreatedAt()); webAccount = (WebAccount) this.add(webAccount, screenName); if (webAccount != null) { webAccount.metaTag(TwitterTags.TWITTER); person.extend(webAccount); } } // add location String twitterLocation = user.getLocation(); if (twitterLocation != null && !twitterLocation.equals("")) { Location location = factory.createLocation(); location.setStringValue(twitterLocation); location = (Location) this.add(location, "uloc_" + user.getId()); if (location != null) { location.metaTag(TwitterTags.TWITTER); person.extend(location); } } // add website String twitterWebsite = user.getURL(); if (twitterWebsite != null) { WebSite website = factory.createWebSite(); website.setAdress(twitterWebsite.toString()); website = (WebSite) this.add(website); if (website != null) { website.metaTag(TwitterTags.TWITTER); person.extend(website); } } // add profile image String profileImageUrl = user.getBiggerProfileImageURL(); // add original res version if available if (screenName != null && source.isPropertyTrueElseDefault(TwitterProperties.LOAD_HIGHER_RES_PROFILE_IMAGE_PROPERTY, TwitterProperties.LOAD_HIGHER_RES_PROFILE_IMAGE_DEFAULT)) { if (user.getOriginalProfileImageURL() != null) { profileImageUrl = user.getOriginalProfileImageURL(); } } if (profileImageUrl != null) { // create image Image profileImage = person.attachImage(profileImageUrl); profileImage.tag(TwitterTags.TWITTER); profileImage.tag(TwitterTags.PROFILE_IMAGE); } // add latest status of user Status status = user.getStatus(); if (status != null && source.isPropertyTrue(TwitterProperties.ADD_STATUS_OF_PEOPLE_PROPERTY)) { createContentFromTweet(person, status); } return person; }
From source file:org.soluvas.buzz.twitter.TwitterUser.java
License:Apache License
/** * Clones attributes from Twitter4j's {@link User}. * @param src//ww w . ja v a2 s .c o m */ 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 void setConnectionValues(Twitter api, ConnectionValues values) { try {//ww w . ja va 2 s.co m User user = api.verifyCredentials(); values.setProviderUserId(Long.toString(user.getId())); values.setDisplayName("@" + user.getScreenName()); values.setProfileUrl("http://twitter.com/" + user.getScreenName()); values.setImageUrl(user.getProfileImageURL()); } catch (TwitterException e) { } }
From source file:org.springframework.social.showcase.twitter.connect.TwitterApiAdapter.java
License:Apache License
@Override public UserProfile fetchUserProfile(Twitter api) { try {/* w w w . java2 s.com*/ 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. j a v a2s . c om 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();/*from w ww.ja v a2s . 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. ja 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 reifyTweet(Status t, TopicMap tm) { Topic tweetTopic = null;/*from ww w . j ava 2 s .c o m*/ try { long tId = t.getId(); String msg = t.getText(); User user = t.getUser(); if (user == null) { tweetTopic = reifyTweet(tId, null, msg, tm); } else { String userScreenName = user.getScreenName(); tweetTopic = reifyTweet(tId, userScreenName, msg, tm); Topic userTopic = reifyTwitterUser(user, tm); if (tweetTopic != null && userTopic != null) { Association a = tm.createAssociation(getTwitterFromUserType(tm)); a.addPlayer(tweetTopic, getTweetType(tm)); a.addPlayer(userTopic, getTwitterUserType(tm)); } } /* String toUser = t.getToUser(); if(toUser != null) { long toUid = t.getToUserId(); Topic toUserTopic = reifyTwitterUser(toUser, toUid, tm); if(tweetTopic != null && toUserTopic != null) { Association a = tm.createAssociation(getTwitterToUserType(tm)); a.addPlayer(tweetTopic, getTweetType(tm)); a.addPlayer(toUserTopic, getTwitterUserType(tm)); } } */ Date d = t.getCreatedAt(); if (tweetTopic != null && d != null) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateStr = df.format(d); tweetTopic.setData(getTweetDateType(tm), TMBox.getLangTopic(tweetTopic, DEFAULT_LANG), dateStr); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); dateStr = sdf.format(d); Topic dateTopic = ExtractHelper.getOrCreateTopic(DATE_SI_BODY + dateStr, dateStr, getTweetDateType(tm), tm); if (dateTopic != null) { Association a = tm.createAssociation(getTweetDateType(tm)); a.addPlayer(tweetTopic, getTweetType(tm)); a.addPlayer(dateTopic, getTweetDateType(tm)); } } /* String l = t.getIsoLanguageCode(); if(l != null) { Topic tweetLangTopic = TMBox.getLangTopic(tweetTopic, l); if(tweetLangTopic != null) { Association a = tm.createAssociation(getTweetLangType(tm)); a.addPlayer(tweetTopic, getTweetType(tm)); a.addPlayer(tweetLangTopic, getTweetLangType(tm)); } } */ GeoLocation geo = t.getGeoLocation(); if (geo != null) { double lat = geo.getLatitude(); double lon = geo.getLongitude(); String geoLocStr = lat + "," + lon; tweetTopic.setData(getTweetGeoLocationType(tm), TMBox.getLangTopic(tweetTopic, DEFAULT_LANG), geoLocStr); } HashtagEntity[] entities = t.getHashtagEntities(); if (entities != null && entities.length > 0) { for (int i = 0; i < entities.length; i++) { Topic entityTopic = reifyHashtagEntity(entities[i], tm); if (entityTopic != null) { Association a = tm.createAssociation(getHashtagType(tm)); a.addPlayer(tweetTopic, getTweetType(tm)); a.addPlayer(entityTopic, getHashtagType(tm)); } } } MediaEntity[] mediaEntities = t.getMediaEntities(); if (mediaEntities != null && mediaEntities.length > 0) { for (int i = 0; i < mediaEntities.length; i++) { Topic entityTopic = reifyMediaEntity(mediaEntities[i], tm); if (entityTopic != null) { Association a = tm.createAssociation(getMediaEntityType(tm)); a.addPlayer(tweetTopic, getTweetType(tm)); a.addPlayer(entityTopic, getMediaEntityType(tm)); } } } URLEntity[] urlEntities = t.getURLEntities(); if (urlEntities != null && urlEntities.length > 0) { for (int i = 0; i < urlEntities.length; i++) { Topic entityTopic = reifyUrlEntity(urlEntities[i], tm); if (entityTopic != null) { Association a = tm.createAssociation(getURLEntityType(tm)); a.addPlayer(tweetTopic, getTweetType(tm)); a.addPlayer(entityTopic, getURLEntityType(tm)); } } } } catch (Exception e) { log(e); } return tweetTopic; }
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;/* ww w .j a v a 2s. 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.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();// ww w.j a v a 2 s . c om 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(); }