Created
June 4, 2013 06:35
-
-
Save tsux89/5704003 to your computer and use it in GitHub Desktop.
特定のユーザーのフォロワーのスクリーンネームを出力します。
外部ファイルに出力したい場合は、**This File Name** > **Output File**でcmdに入力しちゃってください。
CK/CSはTwitter4iPhoneのものです。
(あ、API制限に気をつけて)
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
require "rubygems" | |
gem 'twitter' | |
require "twitter" | |
CONSUMER_KEY = 'IQKbtAYlXLripLGPWd0HUA' | |
CONSUMER_SECRET = 'GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU' | |
OAUTH_TOKEN = '' | |
OAUTH_TOKEN_SECRET = '' | |
# Twitter gemでのアカウントの認証。 | |
$twitter = Twitter::Client.new( | |
:consumer_key => CONSUMER_KEY, | |
:consumer_secret => CONSUMER_SECRET, | |
:oauth_token => OAUTH_TOKEN, | |
:oauth_token_secret => OAUTH_TOKEN_SECRET | |
) | |
count = 0 | |
nextcursor = nil | |
stop = false | |
# usernameの定義 | |
username = "" | |
while !stop | |
if count != 0 | |
f = $twitter.followers(username, {:cursor=>nextcursor}) | |
else | |
f = $twitter.followers(username) | |
end | |
nextcursor = f.next_cursor | |
followers = f.users | |
if followers.size == 0 | |
stop = true | |
break | |
end | |
followers.each do |follower| | |
sn = follower.screen_name | |
count += 1 | |
if !sn.nil? | |
puts "#{sn}" | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment