Skip to content

Instantly share code, notes, and snippets.

@tsux89
Last active August 29, 2015 13:57
Show Gist options
  • Save tsux89/9461164 to your computer and use it in GitHub Desktop.
Save tsux89/9461164 to your computer and use it in GitHub Desktop.
Rubyで書いたけど動かない。 (Twitter 5.7.1, Tweetstream 2.6.1)
require 'twitter'
API_KEY = ''
API_SECRET = ''
ACCESS_TOKEN = ''
ACCESS_SECRET = ''
rest = Twitter::REST::Client.new do |config|
config.consumer_key = API_KEY
config.consumer_secret = API_SECRET
config.access_token = ACCESS_TOKEN
config.access_token_secret = ACCESS_SECRET
end
stream = Twitter::Streaming::Client.new do |config|
config.consumer_key = API_KEY
config.consumer_secret = API_SECRET
config.access_token = ACCESS_TOKEN
config.access_token_secret = ACCESS_SECRET
end
ptn = /\@#{rest.users} //正規表現でscreen_nameを取得、パターン合致させるために、update_nameも条件に入れるようにする
# coding: utf-8
# require modules
require 'twitter'
require 'tweetstream'
require 'pp'
# difine keys
ck = 'azgVq54dY3uQ90l5tdUg'
cs = 'I1p5JIZqldnuiVcuc1sW3GxXUVRDUEAMGkLJo6d8Y'
at = ''
ats = ''
# configure to define keys on twitter modules
$host = Twitter::REST::Client.new do |config|
config.consumer_key = ck
config.consumer_secret = cs
config.access_token = at
config.access_token_secret = ats
end
$host.update("イクゥ")
client = Twitter::Streaming::Client.new do |config|
config.consumer_key = ck
config.consumer_secret = cs
config.access_token = at
config.access_token_secret = ats
end
client.user do |status|
open("hoge.txt", "a") {|f|
pp status
f.write status
f.write("\n")
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment