Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Created January 5, 2011 18:07
Show Gist options
  • Save rummelonp/766705 to your computer and use it in GitHub Desktop.
Save rummelonp/766705 to your computer and use it in GitHub Desktop.
おっぱいツイートをStreamingAPIで待ち受けてGrowlするだけのRubyスクリプト
# -*- coding: utf-8 -*-
require 'rubygems'
require 'rubytter'
require 'yaml'
OAUTH_PATH = "*** oauth yaml path ***"
oauth = YAML.load_file(OAUTH_PATH)
consumer = OAuth::Consumer.
new(oauth[:consumer_key],
oauth[:consumer_secret],
site: "http://stream.twitter.com/")
token = OAuth::AccessToken.
new(consumer,
oauth[:oauth_token],
oauth[:oauth_token_secret])
twitter = OAuthRubytter.new(token)
path = '/1/statuses/filter.json'
params = {'track' => 'おっぱい'}
http = consumer.send(:create_http)
post = consumer.
create_signed_request(:post,
path,
token,
{},
params,
twitter.header)
http.request(post) do |response|
response.read_body do |chunk|
status = JSON.parse(chunk) rescue next
if status['text']
`/usr/local/bin/growlnotify "#{status['user']['screen_name']}" -m "#{status['text']}"`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment