0

我正在开发和应用程序,我想从 Twitter 获取一些提要,例如图片、名称、推文、时间和每条推文的回复次数。我做了所有但无法获得每条推文的回复数量......提前帮助我......我也在发布我的代码。

Twitter unauthenticatedTwitter = new TwitterFactory().getInstance();
                 Paging paging = new Paging(1, 100);
                 List<twitter4j.Status> statuses = unauthenticatedTwitter.getUserTimeline("BeingSalmanKhan",paging);

                         for (Status status3 : statuses) 
                          {
                             TwitterFeeds tFeeds = new TwitterFeeds();
                                 System.out.println(status3.getText());
                                 tFeeds.strTweet = status3.getText();
                                 tFeeds.strDate  = status3.getCreatedAt().toString();
                                 System.out.println("---------------------------------- " + status3.getSource());

                                 al_tweets.add(tFeeds);

                          }
                         str_tw_name    =   unauthenticatedTwitter.showUser("BeingSalmanKhan").getName();
                         str_tw_imgurl  =   unauthenticatedTwitter.showUser("BeingSalmanKhan").getProfileImageURL().toString();



                         bitmap_twpic = NewsActivity.DownloadImage(str_tw_imgurl);
4

2 回答 2

1

试试这段代码……它对我有用……希望对你也有用

try {
                   Twitter unauthenticatedTwitter = new TwitterFactory().getInstance();
                   //URLEntity[] uent= 
                 //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<twitter4j.Status> statuses = unauthenticatedTwitter.getUserTimeline("ashabhosle",paging);
                 System.out.println("status no 2 ="+statuses.get(2).toString());
                 long retweetcnt=statuses.get(2).getRetweetCount();
                 System.out.println("retweet count on 2nd tweet "+retweetcnt);
                         for (Status status3 : statuses) 
                          {
                                 System.out.println(status3.getText());
                          }
            } 
               catch (Exception e) {
                e.printStackTrace();
                System.out.println("Failed to get timeline: " + e.getMessage());

            }
于 2012-06-18T08:01:36.730 回答
0

尝试 getRelatedResults(),给出回复 + 提及的列表,它最接近获得回复。

于 2012-06-18T04:24:02.407 回答