List of usage examples for twitter4j User getURL
String getURL();
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.//from w w w . j a va 2 s. c om * * @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/* w ww. j a v a 2 s . 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.tweetalib.android.model.TwitterUser.java
License:Apache License
public TwitterUser(User user) { mId = user.getId();/*from w w w .j a va 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;/* w w w. ja va 2 s .co 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 va2 s .com 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:org.yukung.following2ldr.command.impl.FindFeedUrlCommand.java
License:Apache License
@Override public void run() throws Throwable { // Twitter??//from w w w.jav a2s . com long start = System.currentTimeMillis(); String consumerKey = config.getProperty(Constants.CONSUMER_KEY); String consumerSecret = config.getProperty(Constants.CONSUMER_SECRET); String userName = params.get(0); Twitter twitter = new TwitterFactory().getInstance(); twitter.setOAuthConsumer(consumerKey, consumerSecret); RequestToken requestToken = twitter.getOAuthRequestToken(); String authorizationURL = requestToken.getAuthorizationURL(); System.out.println(":" + authorizationURL); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Please enter the PIN:"); String pin = br.readLine(); AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, pin); twitter.setOAuthAccessToken(accessToken); long cursor = -1L; IDs friendIDs; List<Long> iDsList = new ArrayList<Long>(5000); do { friendIDs = twitter.getFriendsIDs(userName, cursor); long[] iDs = friendIDs.getIDs(); for (long iD : iDs) { iDsList.add(iD); } cursor = friendIDs.getNextCursor(); } while (friendIDs.hasNext()); List<long[]> list = new ArrayList<long[]>(); int offset = 0; long[] tmp = new long[100]; for (Long id : iDsList) { if (offset < 100) { tmp[offset] = id; offset++; } else { list.add(tmp); offset = 0; tmp = new long[100]; } } list.add(tmp); List<URL> urlList = new ArrayList<URL>(); for (long[] array : list) { ResponseList<User> lookupUsers = twitter.lookupUsers(array); for (User user : lookupUsers) { log.info("URL:" + user.getURL()); urlList.add(user.getURL()); } } String path = "C:\\Users\\ikeda_yusuke\\Documents\\sandbox\\java\\data\\" + userName + ".txt"; FileWriter writer = new FileWriter(path); BufferedWriter out = new BufferedWriter(writer); // PrintWriter pw = new PrintWriter(writer); for (URL url : urlList) { if (url != null) { out.write(url.toString() + "\n"); } } out.flush(); out.close(); long end = System.currentTimeMillis(); log.info("?:" + (end - start) + " ms"); // ??IDor?? // Twitter API??????ID? // ?????ID?URL100??? // ??URL? }
From source file:twitbak.TwitBak.java
License:Open Source License
/** * Returns a JSONObject containing user data. * @param user//from w w w. j a v a 2s. 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:TwitterLookUpUsers.LookupUsers.java
License:Apache License
public static void main(String[] args) throws InterruptedException { Postgresql.DBBaglan();/*from w ww . j a va2s.c o m*/ Postgresql.DBSelect(); Twitter twitter = new TwitterFactory().getInstance(); for (int j = 0; j < sonuc.length; j++) { try { User user = twitter.showUser(sonuc[j]); if (user.getStatus() != null) { System.out.println((j + 1) + ". Sorgu___________________________________"); System.out.println("@" + user.getScreenName()); System.out.println(user.getTimeZone()); System.out.println("@" + user.getName()); System.out.println("@" + user.getURL()); System.out.println("LOKASYONN : " + user.getLocation()); System.out.println("@" + user.getDescription()); System.out.println("@" + user.getOriginalProfileImageURL()); System.out.println("@" + user.getMiniProfileImageURL()); System.out.println("@" + user.getProfileBackgroundImageURL()); System.out.println("_______________________________________________"); if (lokasyon[j].contains(user.getLocation())) { System.out.println("KULLANICI BU OLABLR*************************"); } } else { // the user is protected System.out.println((j + 1) + ". Sorgu______________________________________"); System.out.println("@" + user.getScreenName() + "---- KULLANICI PUBLIC DEL"); System.out.println("___________________________________________________"); } } catch (TwitterException te) { te.printStackTrace(); if ((te.getErrorCode() == 88)) { System.err.println("EXCEED.............."); Thread.sleep(900000); //wait 15 min } System.out.println(); } } System.exit(0); }
From source file:uk.ac.susx.tag.method51.twitter.Tweet.java
License:Apache License
public Tweet(Status status) { this();/*from ww w .ja v a 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); } }