Not being able to fetch certain profile's tweets

DAbramovici
@DAbramovici Daniel Abramovici

I am currently developing a java application that fetches the 5 most recent tweets from certain pre-especified profiles, but there are a few profiles wich I'm having trouble getting the tweets from. Searching them on the website works fine, but using the search query I am unable to retrieve them. I am currently using the twitter4J library. Below is an example of the code and the profiles that present the error:

Twitter twitter = new TwitterFactory().getInstance();
Query query = new Query("from:"+source);
query.setRpp(5);
QueryResult result = twitter.search(query);
System.out.println(twitterSource);
System.out.println("Count : " + result.getTweets().size()) ;

profiles that do not work (These profile return a count of 0 tweets):
CETSP_
carromesmo

Thanks in advance for the help

Daniel

1 week 5 days ago

Replies

episod
@episod Taylor Singletary

The Search API is not the right API to use to get a specific user's tweets -- their user timeline is more appropriate. See this FAQ:

Why are the Tweets I'm looking for not in Twitter Search, the Search API, or Search widgets?

Twitter's search is optimized to serve relevant tweets to end-users in response to direct, non-recurring queries such as #hashtags, URLs, domains, and keywords. The Search API (which also powers Twitter's search widget) is an interface to this search engine. Our search service is not meant to be an exhaustive archive of public tweets and not all tweets are indexed or returned. Some results are refined to better combat spam and increase relevance. Due to capacity constraints, the index currently only covers about a week's worth of tweets.

The user timeline API is the definitive source of tweets by a specific author. For a collection of recent Tweets by more than one user, consider creating a Twitter List and leveraging the list timeline. The Streaming API is often the best-fit choice when seeking completeness.

If the tweets you're looking for aren't available in search and you think they should be, consult this support topic for further instructions to contact @Support.

1 week 5 days ago