Created
April 21, 2013 04:07
-
-
Save QB/5428447 to your computer and use it in GitHub Desktop.
Twitter の片思いを取得する。ハッシュからキーを指定して要素を取り出す方法がよく分からなかったので、要素の番号を指定するという呆れるほどの原始的な営みをしてみた。
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 "twitter" | |
Twitter.configure do |config| #4つのトークンを各自で指定してね | |
config.consumer_key = "" | |
config.consumer_secret = "" | |
config.oauth_token = "" | |
config.oauth_token_secret = "" | |
end | |
print "どのユーザの片思いを取得するの? \n screen_name :" | |
user = STDIN.gets.chomp | |
friend = Twitter.friend_ids(user) | |
follower = Twitter.follower_ids(user) | |
kataomoi = friend.attrs.values[0] - follower.attrs.values[0] | |
for n in 0..kataomoi.length-1 do | |
user = Twitter.user(kataomoi[n]) | |
puts user.attrs.values[3] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Object#methods で
user.methods
ってやるとメソッドの一覧が取れるのでuser.attrs.values[3]
みたいにしなくてもuser.screen_name
みたいなメソッド名分かると思う:;(∩´﹏`∩);: