List of usage examples for twitter4j User getName
String getName();
From source file:net.lacolaco.smileessence.viewmodel.EventViewModel.java
License:Open Source License
public EventViewModel(EnumEvent event, User source, Status status) { this.event = event; this.createdAt = new Date(); this.sourceUserID = source.getId(); this.sourceScreenName = source.getScreenName(); this.sourceName = source.getName(); this.iconURL = source.getProfileImageURL(); if (status != null) { if (event == EnumEvent.RETWEETED) { this.targetStatusID = status.getRetweetedStatus().getId(); this.targetText = status.getRetweetedStatus().getText(); } else {//from w ww . j a va 2s .co m this.targetStatusID = status.getId(); this.targetText = status.getText(); } } else { this.targetStatusID = -1L; this.targetText = ""; } }
From source file:net.lacolaco.smileessence.viewmodel.StatusViewModel.java
License:Open Source License
public StatusViewModel(Status status, Account account) { if (status.isRetweet()) { retweetedStatus = new StatusViewModel(status.getRetweetedStatus(), account); }//from w w w .ja va 2 s . c o m id = status.getId(); text = TwitterUtils.replaceURLEntities(status.getText(), status.getURLEntities(), false); createdAt = status.getCreatedAt(); source = status.getSource(); mentions = status.getUserMentionEntities(); hashtags = status.getHashtagEntities(); media = status.getMediaEntities(); urls = status.getURLEntities(); symbols = status.getSymbolEntities(); User user = status.getUser(); UserCache.getInstance().put(user); userID = user.getId(); screenName = user.getScreenName(); name = user.getName(); iconURL = user.getProfileImageURLHttps(); isProtected = user.isProtected(); setMention(isMention(account.screenName)); setMyStatus(isMyStatus(account.userID)); setRetweetOfMe(isRetweetOfMe(account.userID)); }
From source file:net.lacolaco.smileessence.viewmodel.UserViewModel.java
License:Open Source License
public UserViewModel(User user) { id = user.getId();/*from www. j a va 2 s . co m*/ screenName = user.getScreenName(); name = user.getName(); description = user.getDescription(); location = user.getLocation(); url = user.getURL(); iconURL = user.getBiggerProfileImageURL(); bannerURL = user.getProfileBannerURL(); statusesCount = user.getStatusesCount(); friendsCount = user.getFriendsCount(); followersCount = user.getFollowersCount(); favoritesCount = user.getFavouritesCount(); isProtected = user.isProtected(); isVerified = user.isVerified(); }
From source file:net.nitram509.controller.TwitterCallbackHttpController.java
License:Open Source License
private UserProfile retrieveUserProfileDetails(Twitter twitter, AccessToken accessToken) throws TwitterException { final long twitterId = twitter.getId(); User twitterUser = twitter.users().showUser(twitterId); UserProfile userProfile = new UserProfile(new UserId(twitterId)); userProfile.setName(twitterUser.getName()); userProfile.setScreenName(twitterUser.getScreenName()); userProfile.setProfileImageUrlHttps(twitterUser.getProfileImageURLHttps()); userProfile.setProfileImageUrl(twitterUser.getProfileImageURL()); userProfile.setUrl(twitterUser.getURL()); userProfile.setAccessToken(accessToken.getToken()); userProfile.setAccessTokenSecret(accessToken.getTokenSecret()); return userProfile; }
From source file:net.wasdev.gameon.auth.twitter.TwitterCallback.java
License:Apache License
/** * Method that performs introspection on an AUTH string, and returns data as * a String->String hashmap.// w ww. j a v a 2s .c o m * * @param auth * the authstring to query, as built by an auth impl. * @return the data from the introspect, in a map. * @throws IOException * if anything goes wrong. */ public Map<String, String> introspectAuth(String token, String tokensecret) throws IOException { Map<String, String> results = new HashMap<String, String>(); ConfigurationBuilder c = new ConfigurationBuilder(); c.setOAuthConsumerKey(key).setOAuthConsumerSecret(secret).setOAuthAccessToken(token) .setOAuthAccessTokenSecret(tokensecret); Twitter twitter = new TwitterFactory(c.build()).getInstance(); try { // ask twitter to verify the token & tokensecret from the auth // string // if invalid, it'll throw a TwitterException twitter.verifyCredentials(); // if it's valid, lets grab a little more info about the user. long id = twitter.getId(); ResponseList<User> users = twitter.lookupUsers(id); User u = users.get(0); String name = u.getName(); String screenname = u.getScreenName(); results.put("valid", "true"); results.put("id", "twitter:" + id); results.put("name", name); results.put("screenname", screenname); } catch (TwitterException e) { results.put("valid", "false"); } return results; }
From source file:nz.net.speakman.android.dreamintweets.twitterstream.TwitterStreamAdapter.java
License:Apache License
private Spanned getTweetAuthor(Status tweet) { User user = tweet.getUser(); return Html.fromHtml(getClickableUrl(getUserUrl(user), user.getName())); }
From source file:org.apache.asterix.external.parser.TweetParser.java
License:Apache License
@Override public void parse(IRawRecord<? extends Status> record, DataOutput out) throws HyracksDataException { Status tweet = record.get();/*from w w w.ja v a 2 s.com*/ User user = tweet.getUser(); // Tweet user data ((AMutableString) mutableUserFields[userFieldNameMap.get(Tweet.SCREEN_NAME)]) .setValue(JObjectUtil.getNormalizedString(user.getScreenName())); ((AMutableString) mutableUserFields[userFieldNameMap.get(Tweet.LANGUAGE)]) .setValue(JObjectUtil.getNormalizedString(user.getLang())); ((AMutableInt32) mutableUserFields[userFieldNameMap.get(Tweet.FRIENDS_COUNT)]) .setValue(user.getFriendsCount()); ((AMutableInt32) mutableUserFields[userFieldNameMap.get(Tweet.STATUS_COUNT)]) .setValue(user.getStatusesCount()); ((AMutableString) mutableUserFields[userFieldNameMap.get(Tweet.NAME)]) .setValue(JObjectUtil.getNormalizedString(user.getName())); ((AMutableInt32) mutableUserFields[userFieldNameMap.get(Tweet.FOLLOWERS_COUNT)]) .setValue(user.getFollowersCount()); // Tweet data ((AMutableString) mutableTweetFields[tweetFieldNameMap.get(Tweet.ID)]) .setValue(String.valueOf(tweet.getId())); int userPos = tweetFieldNameMap.get(Tweet.USER); for (int i = 0; i < mutableUserFields.length; i++) { ((AMutableRecord) mutableTweetFields[userPos]).setValueAtPos(i, mutableUserFields[i]); } if (tweet.getGeoLocation() != null) { ((AMutableDouble) mutableTweetFields[tweetFieldNameMap.get(Tweet.LATITUDE)]) .setValue(tweet.getGeoLocation().getLatitude()); ((AMutableDouble) mutableTweetFields[tweetFieldNameMap.get(Tweet.LONGITUDE)]) .setValue(tweet.getGeoLocation().getLongitude()); } else { ((AMutableDouble) mutableTweetFields[tweetFieldNameMap.get(Tweet.LATITUDE)]).setValue(0); ((AMutableDouble) mutableTweetFields[tweetFieldNameMap.get(Tweet.LONGITUDE)]).setValue(0); } ((AMutableString) mutableTweetFields[tweetFieldNameMap.get(Tweet.CREATED_AT)]) .setValue(JObjectUtil.getNormalizedString(tweet.getCreatedAt().toString())); ((AMutableString) mutableTweetFields[tweetFieldNameMap.get(Tweet.MESSAGE)]) .setValue(JObjectUtil.getNormalizedString(tweet.getText())); for (int i = 0; i < mutableTweetFields.length; i++) { mutableRecord.setValueAtPos(i, mutableTweetFields[i]); } recordBuilder.reset(mutableRecord.getType()); recordBuilder.init(); IDataParser.writeRecord(mutableRecord, out, recordBuilder); }
From source file:org.apache.asterix.external.util.TweetProcessor.java
License:Apache License
public AMutableRecord processNextTweet(Status tweet) { User user = tweet.getUser(); // Tweet user data ((AMutableString) mutableUserFields[userFieldNameMap.get(Tweet.SCREEN_NAME)]) .setValue(JObjectUtil.getNormalizedString(user.getScreenName())); ((AMutableString) mutableUserFields[userFieldNameMap.get(Tweet.LANGUAGE)]) .setValue(JObjectUtil.getNormalizedString(user.getLang())); ((AMutableInt32) mutableUserFields[userFieldNameMap.get(Tweet.FRIENDS_COUNT)]) .setValue(user.getFriendsCount()); ((AMutableInt32) mutableUserFields[userFieldNameMap.get(Tweet.STATUS_COUNT)]) .setValue(user.getStatusesCount()); ((AMutableString) mutableUserFields[userFieldNameMap.get(Tweet.NAME)]) .setValue(JObjectUtil.getNormalizedString(user.getName())); ((AMutableInt32) mutableUserFields[userFieldNameMap.get(Tweet.FOLLOWERS_COUNT)]) .setValue(user.getFollowersCount()); // Tweet data ((AMutableString) mutableTweetFields[tweetFieldNameMap.get(Tweet.ID)]) .setValue(String.valueOf(tweet.getId())); int userPos = tweetFieldNameMap.get(Tweet.USER); for (int i = 0; i < mutableUserFields.length; i++) { ((AMutableRecord) mutableTweetFields[userPos]).setValueAtPos(i, mutableUserFields[i]); }/*from ww w. j a va 2s .c o m*/ if (tweet.getGeoLocation() != null) { ((AMutableDouble) mutableTweetFields[tweetFieldNameMap.get(Tweet.LATITUDE)]) .setValue(tweet.getGeoLocation().getLatitude()); ((AMutableDouble) mutableTweetFields[tweetFieldNameMap.get(Tweet.LONGITUDE)]) .setValue(tweet.getGeoLocation().getLongitude()); } else { ((AMutableDouble) mutableTweetFields[tweetFieldNameMap.get(Tweet.LATITUDE)]).setValue(0); ((AMutableDouble) mutableTweetFields[tweetFieldNameMap.get(Tweet.LONGITUDE)]).setValue(0); } ((AMutableString) mutableTweetFields[tweetFieldNameMap.get(Tweet.CREATED_AT)]) .setValue(JObjectUtil.getNormalizedString(tweet.getCreatedAt().toString())); ((AMutableString) mutableTweetFields[tweetFieldNameMap.get(Tweet.MESSAGE)]) .setValue(JObjectUtil.getNormalizedString(tweet.getText())); for (int i = 0; i < mutableTweetFields.length; i++) { mutableRecord.setValueAtPos(i, mutableTweetFields[i]); } return mutableRecord; }
From source file:org.apache.flume.sink.solr.morphline.TwitterSource.java
License:Apache License
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) { User user = status.getUser(); Record doc = new Record(avroSchema); doc.put("id", idPrefix + status.getId()); doc.put("created_at", formatterTo.format(status.getCreatedAt())); doc.put("retweet_count", status.getRetweetCount()); doc.put("retweeted", status.isRetweet()); doc.put("in_reply_to_user_id", status.getInReplyToUserId()); doc.put("in_reply_to_status_id", status.getInReplyToStatusId()); addString(doc, "source", status.getSource()); addString(doc, "text", status.getText()); MediaEntity[] mediaEntities = status.getMediaEntities(); if (mediaEntities.length > 0) { addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps()); addString(doc, "expanded_url", mediaEntities[0].getExpandedURL()); }// w w w . j a va2 s . c o m doc.put("user_friends_count", user.getFriendsCount()); doc.put("user_statuses_count", user.getStatusesCount()); doc.put("user_followers_count", user.getFollowersCount()); addString(doc, "user_location", user.getLocation()); addString(doc, "user_description", user.getDescription()); addString(doc, "user_screen_name", user.getScreenName()); addString(doc, "user_name", user.getName()); return doc; }
From source file:org.apache.solr.handler.dataimport.TwitterEntityProcessor.java
License:Apache License
@Override public Map<String, Object> nextRow() { Map<String, Object> row = new HashMap<>(); if (twitter == null || query == null) return null; try {//from w w w . j a v a 2 s . com if (results == null) { results = twitter.search(query); if (results == null || results.getCount() == 0) return null; } if (tweets == null) tweets = (ArrayList<Status>) results.getTweets(); Status tweet = null; if (index < tweets.size()) { tweet = (Status) tweets.get(index++); } else { query = results.nextQuery(); if (query != null) { results = twitter.search(query); if (results == null || results.getCount() == 0) return null; tweets = (ArrayList<Status>) results.getTweets(); index = 0; tweet = (Status) tweets.get(index++); } } if (tweet == null) return null; // id row.put(MESSAGE_ID, tweet.getId()); // lang row.put(MESSAGE_LANG, tweet.getLang()); // user User user = tweet.getUser(); // name row.put(MESSAGE_USER, user.getName()); // pseudo row.put(MESSAGE_PSEUDO, tweet.getUser().getScreenName()); // text row.put(MESSAGE_TEXT, tweet.getText()); // date Date date = tweet.getCreatedAt(); row.put(MESSAGE_DATE, date.toString()); } catch (TwitterException e) { e.printStackTrace(); return null; } return row; }