Created
January 5, 2011 18:07
-
-
Save rummelonp/766705 to your computer and use it in GitHub Desktop.
おっぱいツイートをStreamingAPIで待ち受けてGrowlするだけのRubyスクリプト
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
# -*- 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