1

I want to get tweets by particular user by entering its userId.

I can search for a text by:

     Query query = new Query("Hi");
        QueryResult result;
        do {
            result = twitter.search(query);
            List<Status> tweets = result.getTweets();
            for (Status tweet : tweets) {
                System.out.println("@" + tweet.getUser().getScreenName() + 
                     " - " + tweet.getText());
                }
            } while ((query = result.nextQuery()) != null); 

but how can I search for the tweets by entering particular userId, is there any direct method or I have to apply logic ?

I am trying:

            Status status = twitter.showStatus(id);
            if (status != null){
                System.out.println("@" + status.getUser().getScreenName()
                + " - " + status.getText());}

where id is userId, but by doing this, I am getting the error:

Failed to search tweets: 404:The URI requested is invalid or the resource requested, such as a user, does not exists. Also returned when the requested format is not supported by the requested method. message - No status found with that ID. code - 144

Can anyone please help me with this?

Mohit Kanwar
  • 2,962
  • 7
  • 39
  • 59
u12345
  • 389
  • 2
  • 8
  • 17

1 Answers1

2

With the Twitter API you can get up to ~3200 tweets from an user, to do this you can get the time line from an specific user, see those questions

By the way, you are getting that error because you are using twitter.showStatus(id); with an userid, you need to call twitter.showUser(id) and you won't get that error

Community
  • 1
  • 1
FeanDoe
  • 1,608
  • 1
  • 18
  • 30
  • so does that means that if i want all the tweets from a user which is more than 3200 , i cant get it? – u12345 Apr 09 '15 at 05:35
  • No, if you want all the tweets from an user who has more than 3200 you will need another source (like Topsy, but I don't know how to use it) – FeanDoe Apr 09 '15 at 14:13
  • Is there a way to verify if a given userid is valid - not mine who is using this, but some other twitter user I may want to specify to get their tweets. – Levon Nov 28 '17 at 22:48