Created
August 10, 2017 14:50
-
-
Save ismailmechbal/6d74d5e896a56a2f6893c603b5717f17 to your computer and use it in GitHub Desktop.
Rails -> Twitter post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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