Reputation: 41919
I'm playing around with the Ruby Twitter gem and wish to use the methods that are available on the Cursor object. For example, using the Twitter::Cursor I'm supposed to be able to get a an array of all friends by doing
client.friends.to_a
or get a most recent follower with
client.friends.first
However, in my attempt below, when tried to do client.friends.first
for kanyewest, I got an error which showed that I'm using the Twitter::User
object, not the Twitter::Cursor
undefined method
friends' for #
How can I use the gem to get a cursor object that will allow me to query Kanye's friends. client.friends.to_a
Note, I read the documentation for creating a new cursor object but I found it a little abstract. I'm not sure if you're supposed to call the constructor directly? If so, please show me how I'd do that
- (Twitter::Cursor) initialize(attrs, key, klass, request)
My Failing code
#!/usr/bin/env ruby
require 'rubygems'
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = "8nwa....."
config.consumer_secret = "Wj20r....."
config.access_token = "363......"
config.access_token_secret = "7eydU2n....."
end
kanyewest = client.user("kanyewest")
puts kanyewest.friends.first
Upvotes: 1
Views: 600
Reputation: 2197
client.friends("kanyewest").first
should work. friends
is a method on client
not on Twitter::User
Upvotes: 1