DEV Community

Cover image for Meta's Threads Client for Ruby
Derek Nguyen
Derek Nguyen

Posted on

Meta's Threads Client for Ruby

In today's digital landscape, social media platforms have become integral to our personal and professional lives. Meta's Threads, a popular social media platform, provides users with a powerful means of communication and sharing content. To enhance the development experience for Ruby developers, we are thrilled to introduce Threads Client Ruby, a comprehensive library that simplifies the process of creating engaging posts with text, images, links, and replies on Meta's Threads.

🚀 Public repo: Threads Client Ruby

📌 Key Features and Benefits:

Getting Started:

To start leveraging the power of Threads Client Ruby for creating captivating posts on Meta's Threads, follow these simple steps:

  • Install the Gem: Install the gem by executing the following command in your Ruby environment: gem install threads_client.
gem install threads_client_ruby
Enter fullscreen mode Exit fullscreen mode

Usage:

🌀 Config Threads

Using username and password (first time)

credentials = {
  username: "Instagram's username",
  password: "Instagram's password"
}

ThreadsClientRuby.config do |config|
  config.credentials = credentials
end
Enter fullscreen mode Exit fullscreen mode

Using usertoken and userid (get from here)

credentials = {
  usertoken: "token received after login successfull",
  userid: "Instagram's user id"
}

ThreadsClientRuby.config do |config|
  config.credentials = credentials
end
Enter fullscreen mode Exit fullscreen mode

💡 TIP: Using usertoken and userid to avoid Theard rate limit and decrease response time.

🤖 Get usertoken and userid

  userinfo = ThreadsClientRuby.get_userinfo
  # {
  #   :usertoken=> "eyJkc191c2VyX2lkIjoiNTgzOTIyMTY....",
  #   :userid=>"583922..."
  # }
Enter fullscreen mode Exit fullscreen mode

✨ Text Threads

ThreadsClientRuby.publish(text: 'Hello World!')
Enter fullscreen mode Exit fullscreen mode
✨ Threads with Image
# Online image path
ThreadsClientRuby.publish(text: 'Hello World!', image: 'https://fastly.picsum.photos/id/654/536/354.jpg?hmac=Nqd_oi3EIiPJBAVPYhIUjaEvKpRqLjhtTHkxPmjjo7M')

# Or with local image path
ThreadsClientRuby.publish(text: 'Hello World!', image: '/Users/local-path/logo.jpg')
Enter fullscreen mode Exit fullscreen mode
✨ Threads with Link Attachment
ThreadsClientRuby.publish(url: 'https://github.com/dereknguyen269/threads_client_ruby')
Enter fullscreen mode Exit fullscreen mode
✨ Get Post Id From URL
post_id = ThreadsClientRuby.get_post_id('https://www.threads.net/t/CugF-EjhQ3r')
# => 3143538795635609067
Enter fullscreen mode Exit fullscreen mode
✨ Reply to Other Threads
ThreadsClientRuby.publish(reply_id: post_id, text: "Reply to #{post_id}")
Enter fullscreen mode Exit fullscreen mode

Conclusion:

Threads Client Ruby provides Ruby developers with a seamless and efficient solution for creating engaging posts on Meta's Threads. With support for text, images, links, and replies, this gem empowers developers to build innovative social media tools, automate posting processes, and enhance user experiences on the platform. Unlock the potential of Meta's Threads and captivate your audience with captivating posts using Threads Client Ruby today.

Top comments (1)

Collapse
 
snapthre profile image
SnapThreads.net Threads video downloader • Edited

good, I use snapthreads.net to download videos Threads