public static JSONObject getUser(String screen_name, boolean forceReload) throws TwitterException, IOException { if (!forceReload) { JsonFactory mapcapsule = DAO.user_dump.get("screen_name",screen_name); if (mapcapsule == null) mapcapsule = DAO.user_dump.get("id_str", screen_name); if (mapcapsule != null) { JSONObject json = mapcapsule.getJSON(); if (json.length() > 0) { // check if the entry is maybe outdated, i.e. if it is empty or too old try { Date d = DAO.user_dump.parseDate(json); if (d.getTime() + DateParser.DAY_MILLIS > System.currentTimeMillis()) return json; } catch (ParseException e) { return json; } } } } TwitterFactory tf = getUserTwitterFactory(screen_name); if (tf == null) tf = getAppTwitterFactory(); if (tf == null) return new JSONObject(); Twitter twitter = tf.getInstance(); User user = twitter.showUser(screen_name); RateLimitStatus rateLimitStatus = user.getRateLimitStatus(); getUserResetTime = System.currentTimeMillis() + rateLimitStatus.getSecondsUntilReset() * 1000; getUserRemaining = rateLimitStatus.getRemaining(); JSONObject json = user2json(user); enrichLocation(json); DAO.user_dump.putUnique(json); return json; }
/** * Returns extended information of a given user, specified by ID or screen name as per the required id parameter below. This information includes design settings, so third party developers can theme their widgets according to a given user's preferences. * <br>This method calls http://twitter.com/users/show * * @param id the ID or screen name of the user for whom to request the detail * @return User * @throws TwitterException when Twitter service or network is unavailable * @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show">Twitter API Wiki / Twitter REST API Method: users show</a> * @deprecated use showUser(id) instead */ public User getUserDetail(String id) throws TwitterException { return showUser(id); }
@Cacheable("findByScreenNameUserCache") public Try<User> findUser(final String userScreenName) { return sessionManager.doWithCurrentTwitter(twitter -> twitter.showUser(userScreenName)); }
@Cacheable("findByUserIdUserCache") public Try<User> findUser(final long userId) { return sessionManager.doWithCurrentTwitter(twitter -> twitter.showUser(userId)); }
Twitter twitter = new TwitterFactory().getInstance(); User user = twitter.showUser("screename");
@Cacheable(value = "userFromUserId", sync = true) public User showUser(final long userId) { return sessionManager.doWithCurrentTwitter( twitter -> twitter.showUser(userId) ).getOrElseThrow( err -> new IllegalStateException("Cannot find user with id " + userId, err) ); }
@Override public void invoke(List<TwitterListener> listeners) throws TwitterException { User user = twitter.showUser(userId); for (TwitterListener listener : listeners) { try { listener.gotUserDetail(user); } catch (Exception e) { logger.warn("Exception at showUser", e); } } } });
@Override public void invoke(List<TwitterListener> listeners) throws TwitterException { User user = twitter.showUser(screenName); for (TwitterListener listener : listeners) { try { listener.gotUserDetail(user); } catch (Exception e) { logger.warn("Exception at showUser", e); } } } });
@Override public Optional<User> getUserFromUserId(String userId) throws UserValidationException { twitter4j.User user; try { user = twitter.showUser(Long.valueOf(userId)); } catch (TwitterException e) { throw new UserValidationException(e); } return Optional.of(User.create(user.getScreenName(), userId, userId)); }
Twitter twitter = (Twitter) request.getSession().getAttribute("twitter"); long userID = twitter.getId(); twitter4j.User newUser=twitter.showUser(twitter.getScreenName()); String name=newUser.getName();
Twitter twitter = new TwitterFactory().getInstance(); User user = twitter.showUser(username); //username could be an String or a Long with the id of the user Status status = user.getStatus();
public User getUser(final long userId) { return sessionManager.doWithCurrentTwitter(twitter -> twitter.showUser(userId)).getOrNull(); }
public void process(Exchange exchange) throws Exception { // send direct message String toUsername = user; if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(TwitterConstants.TWITTER_USER, String.class))) { toUsername = exchange.getIn().getHeader(TwitterConstants.TWITTER_USER, String.class); } String text = exchange.getIn().getBody(String.class); if (toUsername.isEmpty()) { throw new CamelExchangeException("Username not configured on TwitterEndpoint", exchange); } else { log.debug("Sending to: {} message: {}", toUsername, text); User userStatus = endpoint.getProperties().getTwitter().showUser(toUsername); endpoint.getProperties().getTwitter().sendDirectMessage(userStatus.getId(), text); } }
Twitter twitter = new TwitterFactory().getInstance(); User user = twitter.showUser(twitter.getScreenName()); String profileImage = user.getProfileImageURL(); System.out.println("Profile Image URL : " +profileImage);
AccessToken a = new AccessToken(token,secret); Twitter twitter = new TwitterFactory().getInstance(); twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET); twitter.setOAuthAccessToken(a); int i=twitter.getId(); User u=twitter.showUser(i); System.out.println("user name"+u.getName());
/** * @return the Twitter {@link User} associated with this Session. */ public Try<User> getTwitterUser() { final long self = accessToken.getUserId(); return Try.of(twitterHandler::getTwitter).mapTry(twitter -> twitter.showUser(self)); }
Twitter twitter = new TwitterFactory().getInstance(); User user = twitter.showUser("marissamayer"); if (user.getStatus() != null) { int followers = user.getFollowersCount(); if (followers>=1000) { System.out.println("User "+ user.getScreenName()+" Followers " + user.getFollowersCount()); } } else { // the user is protected System.out.println("@" + user.getScreenName()); }
Twitter twitter = new TwitterFactory().getInstance(twitter4JConfiguration); twitter.setOAuthConsumer(consumerKey, consumerSecret); twitter.setOAuthAccessToken(new AccessToken(oauthToken, oauthTokenSecret)); String screenName = twitter.getScreenName(); // Returns authenticating user's screen name. User stephenfry = twitter.showUser("stephenfry"); // Returns extended information of a given user ... List<User> friends = twitter.getFriendsList("stephenfry", -1L); // Returns a cursored collection of user objects ...
ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthConsumerKey(consumerKey); builder.setOAuthConsumerSecret(SecretKet); User user; AccessToken newAcc = new AccessToken(getoken, getokensecret); Twitter twitter = new TwitterFactory(builder.build()) .getInstance(newAcc); try { String mUserName = twitter.getAccountSettings().getScreenName(); user = twitter.showUser(mUserName); String username = user.getName(); String email= user.getEmail(); String oauth_uid = Integer.toString((int) user.getId()); } catch (TwitterException e) { Log.v("ERROR", "API_Get_Twitter_Registration_DATA"+e.toString()) e.printStackTrace(); }
/** * Answers user information for the authenticated user * <p/> * {@sample.xml ../../../doc/twitter-connector.xml.sample twitter:showUser} * * @return a {@link User} object * @throws TwitterException when Twitter service or network is unavailable */ @Processor public User showUser() throws TwitterException { return getConnectionManagement().getTwitterClient().showUser(getConnectionManagement().getTwitterClient().getId()); }