twitter4j.Twitter.showUser()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中twitter4j.Twitter.showUser()方法的一些代码示例,展示了Twitter.showUser()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Twitter.showUser()方法的具体详情如下:
包路径:twitter4j.Twitter
类名称:Twitter
方法名:showUser

Twitter.showUser介绍

[英]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.
This method calls http://twitter.com/users/show
[中]返回给定用户的扩展信息,根据下面所需的ID参数,由ID或屏幕名称指定。这些信息包括设计设置,因此第三方开发人员可以根据给定用户的偏好对其小部件进行主题化。
此方法调用http://twitter.com/users/show

代码示例

代码示例来源:origin: loklak/loklak_server

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;
}

代码示例来源:origin: net.homeip.yusuke/twitter4j

/**
 * 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);
}

代码示例来源:origin: Tristan971/Lyrebird

@Cacheable("findByScreenNameUserCache")
public Try<User> findUser(final String userScreenName) {
  return sessionManager.doWithCurrentTwitter(twitter -> twitter.showUser(userScreenName));
}

代码示例来源:origin: Tristan971/Lyrebird

@Cacheable("findByUserIdUserCache")
public Try<User> findUser(final long userId) {
  return sessionManager.doWithCurrentTwitter(twitter -> twitter.showUser(userId));
}

代码示例来源:origin: stackoverflow.com

Twitter twitter = new TwitterFactory().getInstance();
User user = twitter.showUser("screename");

代码示例来源:origin: Tristan971/Lyrebird

@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)
  );
}

代码示例来源:origin: org.twitter4j/twitter4j-async

@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);
      }
    }
  }
});

代码示例来源:origin: org.twitter4j/twitter4j-async

@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);
      }
    }
  }
});

代码示例来源:origin: HuygensING/timbuctoo

@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));
}

代码示例来源:origin: stackoverflow.com

Twitter twitter = (Twitter) request.getSession().getAttribute("twitter");
     long userID = twitter.getId();
     twitter4j.User newUser=twitter.showUser(twitter.getScreenName());
     String name=newUser.getName();

代码示例来源:origin: stackoverflow.com

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();

代码示例来源:origin: Tristan971/Lyrebird

public User getUser(final long userId) {
  return sessionManager.doWithCurrentTwitter(twitter -> twitter.showUser(userId)).getOrNull();
}

代码示例来源:origin: org.apache.camel/camel-twitter

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);
  }
}

代码示例来源:origin: stackoverflow.com

Twitter twitter = new TwitterFactory().getInstance();
User user = twitter.showUser(twitter.getScreenName());
String profileImage = user.getProfileImageURL();
System.out.println("Profile Image URL : " +profileImage);

代码示例来源:origin: stackoverflow.com

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());

代码示例来源:origin: Tristan971/Lyrebird

/**
 * @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));
}

代码示例来源:origin: stackoverflow.com

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());
   }

代码示例来源:origin: stackoverflow.com

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 ...

代码示例来源:origin: stackoverflow.com

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();
 }

代码示例来源:origin: org.mule.modules/mule-module-twitter

/**
 * 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());
}

相关文章