ddb
ddb

Reputation: 1406

Connect an existing user account permanently to twitter to auto-tweet

I want to be able to connect an existing user account to his twitter account.

I want to give the option for the user to connect his twitter account. After that is done once, I would like to be able to auto-tweet to his account.

How can I achieve this?

Upvotes: 1

Views: 363

Answers (1)

Arihant Godha
Arihant Godha

Reputation: 2459

Try these 2 gems

gem 'omniauth-twitter' and gem "twitter" Register your App on twitter app site .Do the configuration accordingly. After setting the configuration in your controller you just have to do.

    @twitter = Twitter::Client.new(oauth_token: request.env["omniauth.auth"][:credentials][:token], oauth_token_secret: request.env["omniauth.auth"][:credentials][:secret])
    @twitter.update("Your message")
    flash[:notice] = "Successfully tweeted on your account."
    # redirect_to members_user_earns_path
    render "post"

Upvotes: 5

Related Questions