Last active
August 29, 2015 13:57
-
-
Save tsux89/9461164 to your computer and use it in GitHub Desktop.
Rubyで書いたけど動かない。 (Twitter 5.7.1, Tweetstream 2.6.1)
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 '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も条件に入れるようにする |
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
# 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