如何使用twitter gem检索我的个人资料

时间:2014-01-24 13:20:05

标签: ruby twitter twitter-gem

client = Twitter::REST::Client.new do |config|
  config.consumer_key        = "XX"
  config.consumer_secret     = "XY"
  config.access_token        = "ZZ"
  config.access_token_secret = "ZZZ"
end

如何检索我的个人资料信息?

1 个答案:

答案 0 :(得分:2)

您可以执行以下简单步骤来使用 Twitter 客户端gem:

# get user id from user name 
id = client.user( 'user_name' ).id

# read user's timeline by id
timeline = client.user_timeline id

# read user's timeline of yours
your_timeline = client.user_timeline

您可以省略用户名,并获得当前用户的时间表,因此请尝试发出:

user_info = client.user