Created
June 4, 2013 12:03
-
-
Save hrefhref/5705433 to your computer and use it in GitHub Desktop.
This file contains 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 'tweetstream' | |
TweetStream.configure do |config| | |
# Key & Secret d'une app Twitter (https://dev.twitter.com/apps) | |
config.consumer_key = 'xxxx' | |
config.consumer_secret = 'yyyy' | |
# Il faut ensuite autoriser un user sur l'app | |
config.oauth_token = 'zzzz' | |
config.oauth_token_secret = 'dddd' | |
config.auth_method = :oauth | |
end | |
# Pareil mais pour le client twitter (pour envoyer les tweets) | |
Twitter.configure do |config| | |
config.consumer_key = 'xxxx' | |
config.consumer_secret = 'yyyy' | |
config.oauth_token = 'zzzz' | |
config.oauth_token_secret = 'dddd' | |
end | |
@client = TweetStream::Client.new | |
@client.on_error do |message| | |
puts "ERROR: #{message}" | |
end | |
@client.on_reconnect do |timeout, retries| | |
puts "Reconnect timeout:#{timeout} retry:#{retries}" | |
end | |
@client.on_inited do | |
puts "Connected! yay" | |
end | |
@client.track('coincoin') do |tweet| | |
puts "-> @#{tweet[:user][:screen_name]} #{tweet[:text]}" | |
Twitter.update("@#{tweet[:user][:screen_name]} PAN! \_x<") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment