ruby on rails - Check Twitter user relationship created_at? -
i'm stuck trying extract twitter hash , can't seem find out how friendship attributes?
my code:
require 'twitter' require 'rubygems' client = twitter::rest::client.new |config| config.consumer_key = "..." config.consumer_secret = "..." config.access_token = "..." config.access_token_secret = "..." end puts client.friendship('user1','user2').to_s
response:
#<twitter::relationship:0x007f88c1e58de0>
is there way extract info can retrieve hash array of info on relationship? i.e. when friendship created?
i think cannot find created_at other attributes
you can use direct attribute name
data = client.friendship('user1','user2') data.source.screen_name # user1
if not convert json
data = client.friendship('user1','user2').as_json handle = data["target"]["screen_name"] # user2
sample response after as_json
{"source"=> { "id"=>7697764211, "id_str"=>"7697764211", "screen_name"=>"user1", "following"=>true, "followed_by"=>false, "following_received"=>nil, "following_requested"=>nil, "notifications_enabled"=>nil, "can_dm"=>false, "blocking"=>nil, "blocked_by"=>nil, "muting"=>nil, "want_retweets"=>nil, "all_replies"=>nil, "marked_spam"=>nil}, "target"=> { "id"=>2053615711, "id_str"=>"2053615711", "screen_name"=>"use2", "following"=>false, "followed_by"=>true, "following_received"=>nil, "following_requested"=>nil }}
Comments
Post a Comment