List of usage examples for twitter4j User getScreenName
String getScreenName();
From source file:uk.co.cathtanconsulting.twitter.TwitterSource.java
License:Apache License
/** * @param status/*from w w w . j av a 2s.com*/ * * Generate a TweetRecord object and submit to * */ private void extractRecord(Status status) { TweetRecord record = new TweetRecord(); //Basic attributes record.setId(status.getId()); //Using SimpleDateFormat "yyyy-MM-dd'T'HH:mm:ss'Z'" record.setCreatedAtStr(formatterTo.format(status.getCreatedAt())); //Use millis since epoch since Avro doesn't do dates record.setCreatedAtLong(status.getCreatedAt().getTime()); record.setTweet(status.getText()); //User based attributes - denormalized to keep the Source stateless //but also so that we can see user attributes changing over time. //N.B. we could of course fork this off as a separate stream of user info User user = status.getUser(); record.setUserId(user.getId()); record.setUserScreenName(user.getScreenName()); record.setUserFollowersCount(user.getFollowersCount()); record.setUserFriendsCount(user.getFriendsCount()); record.setUserLocation(user.getLocation()); //If it is zero then leave the value null if (status.getInReplyToStatusId() != 0) { record.setInReplyToStatusId(status.getInReplyToStatusId()); } //If it is zero then leave the value null if (status.getInReplyToUserId() != 0) { record.setInReplyToUserId(status.getInReplyToUserId()); } //Do geo. N.B. Twitter4J doesn't give use the geo type GeoLocation geo = status.getGeoLocation(); if (geo != null) { record.setGeoLat(geo.getLatitude()); record.setGeoLong(geo.getLongitude()); } //If a status is a retweet then the original tweet gets bundled in //Because we can't guarantee that we'll have the original we can //extract the original tweet and process it as we have done this time //using recursion. Note: we will end up with dupes. Status retweetedStatus = status.getRetweetedStatus(); if (retweetedStatus != null) { record.setRetweetedStatusId(retweetedStatus.getId()); record.setRetweetedUserId(retweetedStatus.getUser().getId()); extractRecord(retweetedStatus); } //Submit the populated record onto the channel processRecord(record); }
From source file:uk.co.flax.ukmp.twitter.PartyListHandler.java
License:Apache License
private Set<Long> readPartyIds(Twitter twitter, String screenName, String slug, String party) { Set<Long> ids = new HashSet<>(); try {//from w ww . jav a 2s.c o m long cursor = -1; PagableResponseList<User> response = null; do { response = twitter.getUserListMembers(screenName, slug, cursor); for (User user : response) { LOGGER.debug("Read id for user @{}", user.getScreenName()); ids.add(user.getId()); } cursor = response.getNextCursor(); } while (response != null && response.hasNext()); } catch (TwitterException e) { LOGGER.error("Twitter exception updating {} party list : {}", party, e.getMessage()); } return ids; }
From source file:uniandes.cupi2.tweetSpy.mundo.TweeSpy.java
License:Academic Free License
/** * Retorna la lista de amigos del usuario. * @return/*w w w .j a v a 2 s . com*/ * @throws TwitterException */ public ListaDoblementeEncadenada<Usuario> darListaAmigos() throws TwitterException { listaAmigos = new ListaDoblementeEncadenada<Usuario>(); User u1 = null; long cursor = -1; IDs ids; String resp = user.getScreenName(); do { ids = user.getFriendsIDs(resp, cursor); for (long id : ids.getIDs()) { //System.out.println(id); User useri = user.showUser(id); String nombre = useri.getName(); String name = useri.getScreenName(); String url = useri.getOriginalProfileImageURL(); String desc = useri.getDescription(); //Para buscaar por indices ResponseList<Status> estatuses = user.getUserTimeline(name); Usuario nuevoAmigo = new Usuario(nombre, url, desc); nuevoAmigo.recibirTimeline(estatuses); listaAmigos.agregarFinal(nuevoAmigo); // contenedor? } } while ((cursor = ids.getNextCursor()) != 0); return listaAmigos; }
From source file:Utils.ConvertUsers.java
License:Open Source License
public Set<TwitterUser> convertAll(Set<User> users) { Set<TwitterUser> twitterUsers = new HashSet(); TwitterUser twitterUser;/* ww w . jav a 2s. co m*/ for (User user : users) { twitterUser = new TwitterUser(); twitterUser.setCreated_at(user.getCreatedAt()); twitterUser.setDescription(user.getDescription()); twitterUser.setFollowers_count(user.getFollowersCount()); twitterUser.setLang(user.getLang()); twitterUser.setLocation(user.getLocation()); twitterUser.setName(user.getName()); twitterUser.setProfile_image_url(user.getProfileImageURL()); twitterUser.setScreen_name(user.getScreenName()); twitterUser.setIdTwitter(user.getId()); twitterUser.setFriends_count(user.getFriendsCount()); twitterUser.setProfile_banner_url(user.getProfileBannerURL()); twitterUsers.add(twitterUser); } return twitterUsers; }
From source file:Utils.ConvertUsers.java
License:Open Source License
public TwitterUser convertOne(User user) { TwitterUser twitterUser;/*from w ww . j a v a 2 s .co m*/ twitterUser = new TwitterUser(); twitterUser.setCreated_at(user.getCreatedAt()); twitterUser.setDescription(user.getDescription()); twitterUser.setFollowers_count(user.getFollowersCount()); twitterUser.setLang(user.getLang()); twitterUser.setLocation(user.getLocation()); twitterUser.setName(user.getName()); twitterUser.setProfile_image_url(user.getProfileImageURL()); twitterUser.setScreen_name(user.getScreenName()); twitterUser.setIdTwitter(user.getId()); twitterUser.setFriends_count(user.getFriendsCount()); twitterUser.setProfile_banner_url(user.getProfileBannerURL()); return twitterUser; }