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

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

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

Twitter.getUserTimeline介绍

[英]Returns the most recent statuses posted in the last 24 hours from the authenticating user.
This method calls http://twitter.com/statuses/user_timeline
[中]返回验证用户在过去24小时内发布的最新状态。
此方法调用http://twitter.com/statuses/user_timeline

代码示例

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

Twitter unauthenticatedTwitter = new TwitterFactory().getInstance();
//First param of Paging() is the page number, second is the number per page (this is capped around 200 I think.
Paging paging = new Paging(1, 100);
List<Status> statuses = unauthenticatedTwitter.getUserTimeline("google",paging);

代码示例来源:origin: google/data-transfer-project

long id = twitterApi.getId();
monitor.debug(() -> format("Getting tweets for %s (page %s)", id, page));
ResponseList<Status> statuses = twitterApi.getUserTimeline(id, paging);
List<PhotoModel> photos = new ArrayList<>();
for (Status status : statuses) {

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

ConfigurationBuilder builder=new ConfigurationBuilder();
     builder.setUseSSL(true);
     builder.setApplicationOnlyAuthEnabled(true);
     // setup
     Twitter twitter = new TwitterFactory(builder.build()).getInstance();
     // exercise & verify
     twitter.setOAuthConsumer(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
     // OAuth2Token token = twitter.getOAuth2Token();
     twitter.getOAuth2Token();
 statuses = twitter.getUserTimeline("Twitter");

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

ConfigurationBuilder cb = new ConfigurationBuilder();
   cb.setDebugEnabled(true)
       .setOAuthConsumerKey("B***************Q")
       .setOAuthConsumerSecret(
           "l*********************************o")
       .setOAuthAccessToken(
           "1*******************************X")
       .setOAuthAccessTokenSecret(
           "1***************************c");
   TwitterFactory tf = new TwitterFactory(cb.build());
   Twitter twitter = tf.getInstance();
   try {
     List<Status> statuses;
     String user;
     user = "replace with the user name of your choice";
     statuses = twitter.getUserTimeline(user);
     Log.i("Status Count", statuses.size() + " Feeds");
     for (int i = 0; i < statuses.size(); i++) {
       Status status = statuses.get(i);
       Log.i("Tweet Count " + (i + 1), status.getText() + "\n\n");
     }
   } catch (TwitterException te) {
     te.printStackTrace();
   }

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

Twitter twitterConnection = getConnection(); //I assume you already know how to init a connection
ResponseList<Status> results = twitterConnection.getUserTimeline("justinbieber");

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

@Override
  protected List<Status> doDirect() throws TwitterException {
    log.trace("doDirect.getUserTimeline(user={})", user);
    return getTwitter().getUserTimeline(user);
  }
}

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

/**
 * Returns the most recent statuses posted in the last 24 hours from the specified userid.
 * <br>This method calls http://twitter.com/statuses/user_timeline
 *
 * @param id specifies the ID or screen name of the user for whom to return the user_timeline
 * @param sinceId returns only statuses with an ID greater than (that is, more recent than) the specified ID.
 * @return the 20 most recent statuses posted in the last 24 hours from the user
 * @throws TwitterException when Twitter service or network is unavailable
 * @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-friends_timeline">Twitter API Wiki / Twitter REST API Method: statuses friends_timeline</a>
 * @since Twitter4J 2.0.0
 * @deprecated Use getUserTimeline(String id, Paging paging) instead
 */
public List<Status> getUserTimeline(String id, long sinceId) throws TwitterException {
  return getUserTimeline(id, new Paging(sinceId));
}

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

Twitter latestTweetChecker = new TwitterFactory.getInstance();
Paging page = Page(1,1);
List<Status> statusList = latestTweetChecker.getUserTimeline("rye761",page);

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

public static void main (String args[]) throws TwitterException {
  Twitter twitter = new TwitterFactory().getInstance();
  List<Status> statuses = twitter.getUserTimeline("google");
  String hashtag = "#AlphaGo";
  System.out.println("The Twitter page contains " 
            + countTweets(hashtag, statuses) 
            + " tweets with the hashtag : " + hashtag);

}

public static int countTweets(String hashtag, List<Status> statuses){
  return (int) statuses.stream()
             .filter(x -> x.getText().contains(hashtag))
             .count();
}

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

@Override
  public void invoke(List<TwitterListener> listeners) throws TwitterException {
    ResponseList<Status> statuses = twitter.getUserTimeline();
    for (TwitterListener listener : listeners) {
      try {
        listener.gotUserTimeline(statuses);
      } catch (Exception e) {
        logger.warn("Exception at getUserTimeline", e);
      }
    }
  }
});

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

Twitter unauthenticatedTwitter = new TwitterFactory().getInstance();
//First param of Paging() is the page number, second is the number per page (this is capped around 200 I think.
Paging paging = new Paging(1, 100);
List<Status> statuses = unauthenticatedTwitter.getUserTimeline("ameyjadiye",paging);

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

@Override
  public void invoke(List<TwitterListener> listeners)
      throws TwitterException {
    ResponseList<Status> statuses = twitter.getUserTimeline(userId, paging);
    for (TwitterListener listener : listeners) {
      try {
        listener.gotUserTimeline(statuses);
      } catch (Exception e) {
        logger.warn("Exception at getUserTimeline", e);
      }
    }
  }
});

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

@Override
  public void invoke(List<TwitterListener> listeners)
      throws TwitterException {
    ResponseList<Status> statuses = twitter.getUserTimeline(paging);
    for (TwitterListener listener : listeners) {
      try {
        listener.gotUserTimeline(statuses);
      } catch (Exception e) {
        logger.warn("Exception at getUserTimeline", e);
      }
    }
  }
});

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

@Override
protected ResponseList<Status> backfillLoad(final Twitter twitter, final Paging paging) throws TwitterException {
  return twitter.getUserTimeline(targetUser.getValue().getId(), paging);
}

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

@Override
protected List<Status> doPoll() throws TwitterException {
  Paging paging = getLastIdPaging();
  log.trace("doPoll.getUserTimeline(user={}, sinceId={})", user, paging.getSinceId());
  return getTwitter().getUserTimeline(user, paging);
}

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

@Override
  public void invoke(List<TwitterListener> listeners)
      throws TwitterException {
    ResponseList<Status> statuses = twitter.getUserTimeline(screenName,
        paging);
    for (TwitterListener listener : listeners) {
      try {
        listener.gotUserTimeline(statuses);
      } catch (Exception e) {
        logger.warn("Exception at getUserTimeline", e);
      }
    }
  }
});

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

/**
 * Returns the most recent statuses posted in the last 24 hours from the authenticating user.
 * <br>This method calls http://twitter.com/statuses/user_timeline
 *
 * @param count specifies the number of statuses to retrieve.  May not be greater than 200 for performance purposes
 * @param sinceId returns only statuses with an ID greater than (that is, more recent than) the specified ID.
 * @return the 20 most recent statuses posted in the last 24 hours from the user
 * @throws TwitterException when Twitter service or network is unavailable
 * @see <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-friends_timeline">Twitter API Wiki / Twitter REST API Method: statuses friends_timeline</a>
 * @since Twitter4J 2.0.0
 * @deprecated Use getUserTimeline(String id, Paging paging) instead
 */
public List<Status> getUserTimeline(int count, long sinceId) throws TwitterException {
  return getUserTimeline(new Paging(sinceId).count(count));
}

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

final Twitter twitter = new TwitterFactory().getInstance();
final List<Status> statuses = twitter.getUserTimeline(screenName);

for (Status status : statuses) {
  System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
}

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

@Override
protected ResponseList<Status> initialLoad(final Twitter twitter) throws TwitterException {
  return twitter.getUserTimeline(targetUser.getValue().getId());
}

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

ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
   configurationBuilder
       .setOAuthConsumerKey(STAConstants.TWITTER_CONSUMER_KEY);
   configurationBuilder
       .setOAuthConsumerSecret(STAConstants.TWITTER_CONSUMER_SECRET);
   Configuration configuration = configurationBuilder.build();
   TwitterFactory twitterFactory = new TwitterFactory(configuration);
   Twitter twitter = twitterFactory.getInstance();
   AccessToken accessToken = new AccessToken("ACCESS_TOKEN","TOKEN_SECRET");
   twitter.setOAuthAccessToken(accessToken);
   System.out.println(twitter.getUserTimeline("twitter"));

相关文章