Skip to content

Instantly share code, notes, and snippets.

@ismailmechbal
Created August 10, 2017 14:50
Show Gist options
  • Save ismailmechbal/6d74d5e896a56a2f6893c603b5717f17 to your computer and use it in GitHub Desktop.
Save ismailmechbal/6d74d5e896a56a2f6893c603b5717f17 to your computer and use it in GitHub Desktop.
Rails -> Twitter post
class TwitterController < ApplicationController
# To change this template use File | Settings | File Templates.
def initialize
@client = Twitter::REST::Client.new do |config|
config.consumer_key = "xx"
config.consumer_secret = "xx"
config.access_token = "xx-xx"
config.access_token_secret = "xx"
end
end
def tweet_post
tweet = params[:tweet]
message = 'Tweet posted sucessfully'
begin
@client.update(tweet)
rescue Exception => e
message = e.message
end
render text: message
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment