After a week I realized I had not yet written about the Friendship API in Twitter4R and it is one of the simpler the parts of the core library.
Below shows some code to add and remove a friend:
require('rubygems')
gem('twitter4r', '>=0.2.0')
require('twitter')
client = Twitter::Client.new(:login => 'mylogin', :password => 'mypasswd')
# we can add a friend by using their unique integer id or user object.
screen_name = 'myfriend'
user = Twitter::User.find(screen_name)
id = user.id
# Like any of the following....
client.friend(:add, user)
client.friend(:add, id)
# We can also use any of the following APIs to do exactly the same thing...
client.friend(:remove, user)
client.friend(:remove, id)
See related Twitter4R RDoc.
0 comments:
Post a Comment