Created
March 16, 2017 14:17
-
-
Save hamedrnik/4e3e0a3faec3eeec61c8c7e122a3b4b4 to your computer and use it in GitHub Desktop.
Collect tweets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'twitter' | |
| client = Twitter::Streaming::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" | |
| end | |
| # Collecting tweets from /sample endpoint | |
| # https://dev.twitter.com/streaming/reference/get/statuses/sample | |
| client.sample do |object| | |
| puts object.text if object.is_a?(Twitter::Tweet) | |
| end | |
| # Collecting tweets from /filter endpoint | |
| # https://dev.twitter.com/streaming/reference/post/statuses/filter | |
| filter_params[:track] = "foo" | |
| filter_params[:follow] = "1234567787" | |
| filter_params[:locations] = "-122.75,36.8,-121.75,37.8" | |
| filter_params[:language] = "en" | |
| client.filter(filter_params) do |object| | |
| puts object.text if object.is_a?(Twitter::Tweet) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment