Search code examples
rubyapitwitter

Twitter Bot to Likes some tweets using ruby


I am a Ruby beginner currently working on Twitter API's.

So far I learned how to tweet and look for tweets using twitter bot with The Twitter Ruby Gem.

def follow_hello(client)
    client.search("#Hello_World", result_type: "recent").take(20).map do |tweet|
      client.follow(tweet.user)
    end
end

How can I "Like" all the 20 tweets with the #Hello_World?

I tried this, but it doesn't work:

client.search('#Hello_World', result_type: "recent").take(25).each do |like|

Solution

  • There appears to be a "favorite" call that you can make, by passing it a collection of tweets.

    Although I can't test it out at the moment, something like this should work:

    var tweets = client.search("#Hello_World", result_type: "recent").take(20)
    
    client.favorite(tweets)