List of usage examples for twitter4j User getStatusesCount
int getStatusesCount();
From source file:org.soluvas.buzz.twitter.TwitterUser.java
License:Apache License
/** * Clones attributes from Twitter4j's {@link User}. * @param src//from w w w . j a va 2 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.tweetalib.android.model.TwitterUser.java
License:Apache License
public TwitterUser(User user) { mId = user.getId();/* w w w. j av a2 s . co 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.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 w w w.j a v a2s .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:tweetcrawling.TweetCrawler.java
public ArrayList<String> getValueToWrite(Status status) { // Getting the value to be written Long tid = status.getId();/* w w w . j a v a 2 s .c o m*/ String tweetid = tid.toString(); ArrayList<String> valueToWrite = new ArrayList<String>(); User user = status.getUser(); String screenname = user.getScreenName(); String name = user.getName(); String url = getTweetUrl(screenname, tweetid); String body = status.getText().replace("\n", " "); valueToWrite.add(body.replace(",", " ")); // element: body valueToWrite.add(url); // element: id valueToWrite.add(screenname); // element: userid valueToWrite.add(name); // element: user // element: gender if (name != null && !name.isEmpty()) { valueToWrite.add(getUserGender(name)); } else if (screenname != null && !screenname.isEmpty()) { valueToWrite.add(getUserGender(screenname)); } else { valueToWrite.add(""); } valueToWrite.add(user.getLocation()); // element: location valueToWrite.add("" + user.getFollowersCount()); // element: followercount valueToWrite.add("" + user.getFriendsCount()); // element: friendscount valueToWrite.add("" + user.getStatusesCount()); // element: statuscount try { List<String> coor = new ArrayList<String>(); String latitude = "" + status.getGeoLocation().getLatitude(); String longitude = "" + status.getGeoLocation().getLongitude(); coor.add(latitude); coor.add(longitude); if (coor != null && !coor.isEmpty() && coor.size() > 0) { valueToWrite.add(coor.get(0)); // element: latitude valueToWrite.add(coor.get(1)); // element: longitude valueToWrite.add(coor.get(0) + "," + coor.get(1)); } else { valueToWrite.add(null); valueToWrite.add(null); valueToWrite.add(null); } } catch (Exception e) { valueToWrite.add(null); valueToWrite.add(null); valueToWrite.add(null); } try { String geoname = status.getPlace().getName(); String country = status.getPlace().getCountry(); if (geoname != null) { valueToWrite.add(geoname); } else { valueToWrite.add(null); } if (country != null) { valueToWrite.add(country); } else { valueToWrite.add(null); } } catch (Exception e) { valueToWrite.add(null); valueToWrite.add(null); } DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); Date date = status.getCreatedAt(); valueToWrite.add(dateFormat.format(date)); // element: date valueToWrite.add(getDateCrawler()); // element: datecrawler valueToWrite.add(status.getInReplyToScreenName()); // element: replyto String tooltip = ""; try { String geoname = status.getPlace().getName(); if (geoname != null) { tooltip = "user = " + name + ", geoname = " + geoname; } } catch (Exception e) { tooltip = ""; } valueToWrite.add(tooltip.trim()); // element: tooltip valueToWrite.add(SOURCE); // element: source return valueToWrite; }
From source file:tweetcrawling.TweetCrawler.java
public void printTweets(String csvOut) throws IOException, TwitterException { for (Status status : getStatuses()) { // Getting the value to be written Long tid = status.getId(); String tweetid = tid.toString(); ArrayList<String> valueToWrite = new ArrayList<String>(); User user = status.getUser(); String screenname = user.getScreenName(); String name = user.getName(); String url = getTweetUrl(screenname, tweetid); valueToWrite.add(url); // element: id valueToWrite.add(screenname); // element: userid valueToWrite.add(name); // element: user // element: gender if (name != null && !name.isEmpty()) { valueToWrite.add(getUserGender(name)); } else if (screenname != null && !screenname.isEmpty()) { valueToWrite.add(getUserGender(screenname)); } else {//from ww w. j av a2 s .com valueToWrite.add(""); } valueToWrite.add(user.getLocation()); // element: location valueToWrite.add("" + user.getFollowersCount()); // element: followercount valueToWrite.add("" + user.getFriendsCount()); // element: friendscount valueToWrite.add("" + user.getStatusesCount()); // element: statuscount try { List<String> coor = new ArrayList<String>(); String latitude = "" + status.getGeoLocation().getLatitude(); String longitude = "" + status.getGeoLocation().getLongitude(); coor.add(latitude); coor.add(longitude); if (coor != null && !coor.isEmpty() && coor.size() > 0) { valueToWrite.add(coor.get(0)); // element: latitude valueToWrite.add(coor.get(1)); // element: longitude valueToWrite.add(coor.get(0) + "," + coor.get(1)); } else { valueToWrite.add(null); valueToWrite.add(null); valueToWrite.add(null); } } catch (Exception e) { valueToWrite.add(null); valueToWrite.add(null); valueToWrite.add(null); } try { String geoname = status.getPlace().getName(); String country = status.getPlace().getCountry(); if (geoname != null) { valueToWrite.add(geoname); } else { valueToWrite.add(null); } if (country != null) { valueToWrite.add(country); } else { valueToWrite.add(null); } } catch (Exception e) { valueToWrite.add(null); valueToWrite.add(null); } DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); Date date = status.getCreatedAt(); valueToWrite.add(dateFormat.format(date)); // element: date valueToWrite.add(getDateCrawler()); // element: datecrawler valueToWrite.add(status.getText()); // element: body valueToWrite.add(status.getInReplyToScreenName()); // element: replyto String tooltip = ""; try { String geoname = status.getPlace().getName(); if (geoname != null) { tooltip = "user = " + name + ", geoname = " + geoname; } } catch (Exception e) { tooltip = ""; } valueToWrite.add(tooltip.trim()); // element: tooltip valueToWrite.add(SOURCE); // element: source // Write valueToWrite to csv external file FileWriter fw = new FileWriter(csvOut, true); PrintWriter pw = new PrintWriter(fw); String content = "'"; for (int i = 0; i < valueToWrite.size() - 1; i++) { content += valueToWrite.get(i) + "','"; } content += valueToWrite.get(valueToWrite.size()) + "'"; pw.print(content); pw.flush(); pw.close(); fw.close(); } }
From source file:twitbak.TwitBak.java
License:Open Source License
/** * Returns a JSONObject containing user data. * @param user/*from w ww. j av a2 s .c o m*/ * @return * @throws TwitterException * @throws JSONException */ //TODO - should be void to match other Bak classes static JSONObject userToJson(User user) throws TwitterException, JSONException { JSONObject result = new JSONObject(); JSONObject userData = new JSONObject(); userData.put("ID", user.getId()); userData.put("Screen Name", user.getScreenName()); userData.put("Name", user.getName()); userData.put("Description", user.getDescription()); userData.put("Profile Image URL", user.getProfileImageURL()); userData.put("URL", user.getURL()); userData.put("Protected", user.isProtected()); userData.put("Followers", user.getFollowersCount()); userData.put("Created At", user.getCreatedAt().toString()); userData.put("Favorites", user.getFavouritesCount()); userData.put("Friends", user.getFriendsCount()); userData.put("Location", user.getLocation()); userData.put("Statuses", user.getStatusesCount()); userData.put("Profile Background Color", user.getProfileBackgroundColor()); userData.put("Profile Background Image URL", user.getProfileBackgroundImageUrl()); userData.put("Profile Sidebar Border Color", user.getProfileSidebarBorderColor()); userData.put("Profile Sidebar Fill Color", user.getProfileSidebarFillColor()); userData.put("Profile Text Color", user.getProfileTextColor()); userData.put("Time Zone", user.getTimeZone()); result.put("User data", userData); return result; }
From source file:twitterNetwork.Follower.java
public void getDetails(String id) throws Exception { ConfigurationBuilder cb1 = new ConfigurationBuilder(); cb1.setOAuthConsumerKey(consumerKey1); cb1.setOAuthConsumerSecret(consumerSecret1); cb1.setOAuthAccessToken(twitterToken1); cb1.setOAuthAccessTokenSecret(twitterSecret1); ConfigurationBuilder cb2 = new ConfigurationBuilder(); cb2.setOAuthConsumerKey(consumerKey2); cb2.setOAuthConsumerSecret(consumerSecret2); cb2.setOAuthAccessToken(twitterToken2); cb2.setOAuthAccessTokenSecret(twitterSecret2); ConfigurationBuilder cb3 = new ConfigurationBuilder(); cb3.setOAuthConsumerKey(consumerKey3); cb3.setOAuthConsumerSecret(consumerSecret3); cb3.setOAuthAccessToken(twitterToken3); cb3.setOAuthAccessTokenSecret(twitterSecret3); Twitter twitter1 = new TwitterFactory(cb1.build()).getInstance(); Twitter twitter2 = new TwitterFactory(cb2.build()).getInstance(); Twitter twitter3 = new TwitterFactory(cb3.build()).getInstance(); ConfigurationBuilder cb4 = new ConfigurationBuilder(); cb4.setOAuthConsumerKey(consumerKey4); cb4.setOAuthConsumerSecret(consumerSecret4); cb4.setOAuthAccessToken(twitterToken4); cb4.setOAuthAccessTokenSecret(twitterSecret4); ConfigurationBuilder cb5 = new ConfigurationBuilder(); cb5.setOAuthConsumerKey(consumerKey5); cb5.setOAuthConsumerSecret(consumerSecret5); cb5.setOAuthAccessToken(twitterToken5); cb5.setOAuthAccessTokenSecret(twitterSecret5); ConfigurationBuilder cb6 = new ConfigurationBuilder(); cb6.setOAuthConsumerKey(consumerKey6); cb6.setOAuthConsumerSecret(consumerSecret6); cb6.setOAuthAccessToken(twitterToken6); cb6.setOAuthAccessTokenSecret(twitterSecret6); ConfigurationBuilder cb7 = new ConfigurationBuilder(); cb7.setOAuthConsumerKey(consumerKey7); cb7.setOAuthConsumerSecret(consumerSecret7); cb7.setOAuthAccessToken(twitterToken7); cb7.setOAuthAccessTokenSecret(twitterSecret7); ConfigurationBuilder cb8 = new ConfigurationBuilder(); cb8.setOAuthConsumerKey(consumerKey8); cb8.setOAuthConsumerSecret(consumerSecret8); cb8.setOAuthAccessToken(twitterToken8); cb8.setOAuthAccessTokenSecret(twitterSecret8); Twitter twitter4 = new TwitterFactory(cb4.build()).getInstance(); Twitter twitter5 = new TwitterFactory(cb5.build()).getInstance(); Twitter twitter6 = new TwitterFactory(cb6.build()).getInstance(); Twitter twitter7 = new TwitterFactory(cb7.build()).getInstance(); Twitter twitter8 = new TwitterFactory(cb8.build()).getInstance(); setTname(id);/* w w w.j a va2 s. com*/ String twittername = this.tname; System.out.println(twittername); //User u=twitter.showUser(usr); //PrintStream out=new PrintStream(new FileOutputStream("F:\\Projects\\Twitter_Network\\out.txt")); int w1 = 1, w2 = 1, w3 = 1, w4 = 1, w5 = 1, w6 = 1, w7 = 1, w8 = 1; //long id=u.getId(); long lCursor = -1, nextCursor = -1; do { String twitterScreenName = twitter1.getScreenName(); IDs followersIDs = twitter1.getFollowersIDs(twitterScreenName, -1); lCursor = nextCursor; //out.println("###"+nextCursor); //label: if (w1 != 16) { try { followersIDs = twitter1.getFollowersIDs(twitterScreenName, lCursor); long[] ids = followersIDs.getIDs(); String usr = twittername; long[] fofIDs; User user = twitter1.showUser(usr); String userScreenName = user.getScreenName(); IDs followerIDsOfFollowers = twitter1.getFollowersIDs(user.getScreenName(), -1); long[] arrl = fofIDs = followerIDsOfFollowers.getIDs(); int n = arrl.length; int n2 = 0; while (n2 < n) { long subId = arrl[n2]; User user1 = twitter1.showUser(subId); if (user1.getStatusesCount() > 200 && user1.getStatusesCount() < 3200) { this.ar.add(user1.getScreenName()); this.arpic.add(user1.getMiniProfileImageURL()); } ++n2; //TimeUnit.MINUTES.sleep(16); } } catch (Exception e) { e.printStackTrace(); } /*for(long k: followersIDs.getIDs()){ //User p=twitter.showUser(k); out.println(k); }*/ nextCursor = followersIDs.getNextCursor(); w1++; } else if (w2 != 16) { try { followersIDs = twitter2.getFollowersIDs(twitterScreenName, lCursor); long[] ids = followersIDs.getIDs(); String usr = twittername; long[] fofIDs; User user = twitter2.showUser(usr); String userScreenName = user.getScreenName(); IDs followerIDsOfFollowers = twitter2.getFollowersIDs(user.getScreenName(), -1); long[] arrl = fofIDs = followerIDsOfFollowers.getIDs(); int n = arrl.length; int n2 = 0; while (n2 < n) { long subId = arrl[n2]; User user1 = twitter2.showUser(subId); if (user1.getStatusesCount() > 200 && user1.getStatusesCount() < 3200) { this.ar.add(user1.getScreenName()); this.arpic.add(user1.getMiniProfileImageURL()); } ++n2; //TimeUnit.MINUTES.sleep(16); } } catch (Exception e) { e.printStackTrace(); } /*for(long k: followersIDs.getIDs()){ //User p=twitter.showUser(k); out.println(k); }*/ nextCursor = followersIDs.getNextCursor(); w2++; } else if (w3 != 16) { //IDs followerIDs = twitter3.getFollowersIDs(twitterScreenName, -1); try { followersIDs = twitter3.getFollowersIDs(twitterScreenName, lCursor); long[] ids = followersIDs.getIDs(); String usr = twittername; long[] fofIDs; User user = twitter3.showUser(usr); String userScreenName = user.getScreenName(); IDs followerIDsOfFollowers = twitter3.getFollowersIDs(user.getScreenName(), -1); long[] arrl = fofIDs = followerIDsOfFollowers.getIDs(); int n = arrl.length; int n2 = 0; while (n2 < n) { long subId = arrl[n2]; User user1 = twitter3.showUser(subId); if (user1.getStatusesCount() > 200 && user1.getStatusesCount() < 3200) { this.ar.add(user1.getScreenName()); this.arpic.add(user1.getMiniProfileImageURL()); } ++n2; //TimeUnit.MINUTES.sleep(16); } } catch (Exception e) { e.printStackTrace(); } /*for(long k: followersIDs.getIDs()){ //User p=twitter.showUser(k); out.println(k); }*/ nextCursor = followersIDs.getNextCursor(); w3++; } else if (w4 != 16) { //IDs followerIDs = twitter4.getFollowersIDs(twitterScreenName, -1); try { followersIDs = twitter4.getFollowersIDs(twitterScreenName, lCursor); long[] ids = followersIDs.getIDs(); String usr = twittername; long[] fofIDs; User user = twitter4.showUser(usr); String userScreenName = user.getScreenName(); IDs followerIDsOfFollowers = twitter4.getFollowersIDs(user.getScreenName(), -1); long[] arrl = fofIDs = followerIDsOfFollowers.getIDs(); int n = arrl.length; int n2 = 0; while (n2 < n) { long subId = arrl[n2]; User user1 = twitter4.showUser(subId); if (user1.getStatusesCount() > 200 && user1.getStatusesCount() < 3200) { this.ar.add(user1.getScreenName()); this.arpic.add(user1.getMiniProfileImageURL()); } ++n2; //TimeUnit.MINUTES.sleep(16); } } catch (Exception e) { e.printStackTrace(); } /*for(long k: followersIDs.getIDs()){ //User p=twitter.showUser(k); out.println(k); }*/ nextCursor = followersIDs.getNextCursor(); w4++; } else if (w5 != 16) { //IDs followerIDs = twitter5.getFollowersIDs(twitterScreenName, -1); try { followersIDs = twitter5.getFollowersIDs(twitterScreenName, lCursor); long[] ids = followersIDs.getIDs(); String usr = twittername; long[] fofIDs; User user = twitter5.showUser(usr); String userScreenName = user.getScreenName(); IDs followerIDsOfFollowers = twitter5.getFollowersIDs(user.getScreenName(), -1); long[] arrl = fofIDs = followerIDsOfFollowers.getIDs(); int n = arrl.length; int n2 = 0; while (n2 < n) { long subId = arrl[n2]; User user1 = twitter5.showUser(subId); if (user1.getStatusesCount() > 200 && user1.getStatusesCount() < 3200) { this.ar.add(user1.getScreenName()); this.arpic.add(user1.getMiniProfileImageURL()); } ++n2; //TimeUnit.MINUTES.sleep(16); } } catch (Exception e) { e.printStackTrace(); } /*for(long k: followersIDs.getIDs()){ //User p=twitter.showUser(k); out.println(k); }*/ nextCursor = followersIDs.getNextCursor(); w5++; } else if (w6 != 16) { //IDs followerIDs = twitter6.getFollowersIDs(twitterScreenName, -1); try { followersIDs = twitter6.getFollowersIDs(twitterScreenName, lCursor); long[] ids = followersIDs.getIDs(); String usr = twittername; long[] fofIDs; User user = twitter6.showUser(usr); String userScreenName = user.getScreenName(); IDs followerIDsOfFollowers = twitter6.getFollowersIDs(user.getScreenName(), -1); long[] arrl = fofIDs = followerIDsOfFollowers.getIDs(); int n = arrl.length; int n2 = 0; while (n2 < n) { long subId = arrl[n2]; User user1 = twitter6.showUser(subId); if (user1.getStatusesCount() > 200 && user1.getStatusesCount() < 3200) { this.ar.add(user1.getScreenName()); this.arpic.add(user1.getMiniProfileImageURL()); } ++n2; //TimeUnit.MINUTES.sleep(16); } } catch (Exception e) { e.printStackTrace(); } /*for(long k: followersIDs.getIDs()){ //User p=twitter.showUser(k); out.println(k); }*/ nextCursor = followersIDs.getNextCursor(); w6++; } else if (w7 != 16) { //IDs followerIDs = twitter7.getFollowersIDs(twitterScreenName, -1); try { followersIDs = twitter7.getFollowersIDs(twitterScreenName, lCursor); long[] ids = followersIDs.getIDs(); String usr = twittername; long[] fofIDs; User user = twitter7.showUser(usr); String userScreenName = user.getScreenName(); IDs followerIDsOfFollowers = twitter7.getFollowersIDs(user.getScreenName(), -1); long[] arrl = fofIDs = followerIDsOfFollowers.getIDs(); int n = arrl.length; int n2 = 0; while (n2 < n) { long subId = arrl[n2]; User user1 = twitter7.showUser(subId); if (user1.getStatusesCount() > 200 && user1.getStatusesCount() < 3200) { this.ar.add(user1.getScreenName()); this.arpic.add(user1.getMiniProfileImageURL()); } ++n2; //TimeUnit.MINUTES.sleep(16); } } catch (Exception e) { e.printStackTrace(); } /*for(long k: followersIDs.getIDs()){ //User p=twitter.showUser(k); out.println(k); }*/ nextCursor = followersIDs.getNextCursor(); w7++; } else if (w8 != 16) { //IDs followerIDs = twitter8.getFollowersIDs(twitterScreenName, -1); try { followersIDs = twitter8.getFollowersIDs(twitterScreenName, lCursor); long[] ids = followersIDs.getIDs(); String usr = twittername; long[] fofIDs; User user = twitter8.showUser(usr); String userScreenName = user.getScreenName(); IDs followerIDsOfFollowers = twitter8.getFollowersIDs(user.getScreenName(), -1); long[] arrl = fofIDs = followerIDsOfFollowers.getIDs(); int n = arrl.length; int n2 = 0; while (n2 < n) { long subId = arrl[n2]; User user1 = twitter8.showUser(subId); if (user1.getStatusesCount() > 200 && user1.getStatusesCount() < 3200) { this.ar.add(user1.getScreenName()); this.arpic.add(user1.getMiniProfileImageURL()); } ++n2; //TimeUnit.MINUTES.sleep(16); } } catch (Exception e) { e.printStackTrace(); } /*for(long k: followersIDs.getIDs()){ //User p=twitter.showUser(k); out.println(k); }*/ nextCursor = followersIDs.getNextCursor(); w8++; /*if(twitter8.getRateLimitStatus()!=null){ if (twitter8.getRateLimitStatus().get("/users/lookup") != null){ // break label; } }*/ } else { try { TimeUnit.MINUTES.sleep(16); } catch (InterruptedException e) { e.printStackTrace(); } w1 = 1; w2 = 1; w3 = 1; w4 = 1; w5 = 1; w6 = 1; w7 = 1; w8 = 1; } } while (nextCursor != 0); //out.flush(); //out.close(); }
From source file:uk.ac.susx.tag.method51.twitter.Tweet.java
License:Apache License
public Tweet(Status status) { this();/*from w ww. j a va 2 s .c o m*/ created = status.getCreatedAt(); id = status.getId(); text = status.getText(); inReplyToStatusId = status.getInReplyToStatusId(); inReplyToUserId = status.getInReplyToUserId(); originalText = null; retweetId = -1; isTruncated = status.isTruncated(); isRetweet = status.isRetweet(); Status entities = status; if (isRetweet) { Status origTweet = status.getRetweetedStatus(); entities = origTweet; retweetId = origTweet.getId(); originalText = text; text = origTweet.getText(); } StringBuilder sb = new StringBuilder(); for (HashtagEntity e : entities.getHashtagEntities()) { sb.append(e.getText()); sb.append(" "); } hashtags = sb.toString(); sb = new StringBuilder(); for (UserMentionEntity e : entities.getUserMentionEntities()) { sb.append(e.getScreenName()); sb.append(" "); } mentions = sb.toString(); sb = new StringBuilder(); for (URLEntity e : entities.getURLEntities()) { //String url = e.getURL(); String url = e.getExpandedURL(); if (url == null) { url = e.getURL(); if (url != null) { sb.append(url); } } else { sb.append(url); } sb.append(" "); } urls = sb.toString(); sb = new StringBuilder(); //seems to be null if no entries MediaEntity[] mediaEntities = entities.getMediaEntities(); if (mediaEntities != null) { for (MediaEntity e : mediaEntities) { String url = e.getMediaURL(); sb.append(url); sb.append(" "); } mediaUrls = sb.toString(); } else { mediaUrls = ""; } received = new Date(); source = status.getSource(); GeoLocation geoLoc = status.getGeoLocation(); Place place = status.getPlace(); if (geoLoc != null) { geoLong = geoLoc.getLongitude(); geoLat = geoLoc.getLatitude(); } else if (place != null && place.getBoundingBoxCoordinates() != null && place.getBoundingBoxCoordinates().length > 0) { GeoLocation[] locs = place.getBoundingBoxCoordinates()[0]; double avgLat = 0; double avgLon = 0; for (GeoLocation loc : locs) { avgLat += loc.getLatitude(); avgLon += loc.getLongitude(); } avgLat /= locs.length; avgLon /= locs.length; geoLat = avgLat; geoLong = avgLon; } else { geoLong = null; geoLat = null; } twitter4j.User user = status.getUser(); if (user != null) { userId = user.getId(); location = user.getLocation(); screenName = user.getScreenName(); following = user.getFriendsCount(); name = user.getName(); lang = user.getLang(); timezone = user.getTimeZone(); userCreated = user.getCreatedAt(); followers = user.getFollowersCount(); statusCount = user.getStatusesCount(); description = user.getDescription(); url = user.getURL(); utcOffset = user.getUtcOffset(); favouritesCount = user.getFavouritesCount(); this.user = new User(user); } }