0
votes

I have been integrated a twitter feed into my Rails 4 application using this gem.

Able to fetched twitter home timeline feeds using following twitter gem method

Method:

twitter.home_timeline

and this will return last 20 tweets of home_timeline

To fetch first page tweets, i have added following options to the method which will return first 200 tweets in page 1.

Method:

twitter.home_timeline(:page => 1, :count => 200)

Here, everytime i have to provide page number manually like :page => 2, :page => 3,..and so on to fetch next page tweets.

So, is their any method or way to get total page counts for twitter home time tweets using twitter gem?

2

2 Answers

0
votes

As mentioned in the official documentation:

Note: This method can only return up to 800 Tweets, including retweets.

Meaning that you will never be able to get tweets greater than page 4 (while using count as 200)

0
votes

To answer the question in headline, gem simply makes a call and pass all provided parameters, including page and count, to twitter API - see source

  def home_timeline(options = {})
    perform_get_with_objects('/1.1/statuses/home_timeline.json', options, Twitter::Tweet)
  end

So whatever logic you get is logic from the twitter API. For API, you can read official doc here. Paging is additionally explained here. As indicated in other answer, there is a limit for statuses/home_timeline call:

Up to 800 Tweets are obtainable on the home timeline. It is more volatile for users that follow many users or follow users who tweet frequently.

Meanwhile, you can test the API https://dev.twitter.com/rest/tools/console - was helpful link for me