Auto-following a Twitter account at Omniauth-Twitter signup with Rails5

53 Views Asked by At

I have a website where people sign up via twitter, how can I make those signups to auto follow website’s twitter account? Does API allow me to do that?

1

There are 1 best solutions below

0
Sheikh Azad On

First, the twitter app that is used to sign up via twitter would need to have write permissions. Once they have signed up, you could save their oauth token and secret(which I think you might be doing already). The oauth token and secret can then be used to send a POST request to the the friendships/create endpoint.

POST https://api.twitter.com/1.1/friendships/create.json?user_id=&follow=true

You can get the value for REPLACE_WITH_WEBSITE_TWITTER_ACCOUNT_USER_ID from the twitter apps page.

Here is the reference:

https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/post-friendships-create