README.md in twitter_friendly-1.2.0 vs README.md in twitter_friendly-1.2.1
- old
+ new
@@ -3,28 +3,29 @@
[![Gem Version](https://badge.fury.io/rb/twitter_friendly.png)](https://badge.fury.io/rb/twitter_friendly)
[![Build Status](https://travis-ci.org/ts-3156/twitter_friendly.svg?branch=master)](https://travis-ci.org/ts-3156/twitter_friendly)
The twitter_friendly is a gem to crawl many friends/followers with minimal code. When you want to get a list of friends/followers for a user, all you need to write is the below.
-```
+```ruby
require 'twitter_friendly'
client =
TwitterFriendly::Client.new(
- consumer_key: 'CONSUMER_KEY',
- consumer_secret: 'CONSUMER_SECRET',
- access_token: 'ACCESS_TOKEN',
+ consumer_key: 'CONSUMER_KEY',
+ consumer_secret: 'CONSUMER_SECRET',
+ access_token: 'ACCESS_TOKEN',
access_token_secret: 'ACCESS_TOKEN_SECRET',
- expires_in: 86400 # 1day
+ expires_in: 86400 # 1day
)
ids = []
begin
ids = client.follower_ids('yousuck2020')
rescue Twitter::Error::TooManyRequests => e
- sleep client.rate_limit.follower_ids[:reset_in]
+ seconds = e.rate_limit.reset_in.to_i # or client.rate_limit.follower_ids[:reset_in]
+ sleep seconds
retry
end
puts "ids #{ids.size}"
File.write('ids.txt', ids.join("\n"))
@@ -42,24 +43,24 @@
gem 'twitter_friendly'
```
And then execute:
-```sh
+```bash
$ bundle
```
Or install it yourself as:
-```sh
+```bash
$ gem install twitter_friendly
```
## Configuration
You can pass configuration options as a block to `TwitterFriendly::Client.new` just like the below.
-```
+```ruby
client = TwitterFriendly::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
config.access_token = "YOUR_ACCESS_TOKEN"
config.access_token_secret = "YOUR_ACCESS_SECRET"