Created
November 20, 2011 23:36
-
-
Save johana-star/1381160 to your computer and use it in GitHub Desktop.
Authenticate a twitter session as per the example at http://twitter.rubyforge.org/, but obfuscate the secrets into a YAML config file.
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
require 'twitter' | |
require 'yaml' | |
def authenticate | |
Twitter.configure do |c| | |
config = YAML.load(File.read("config.yml"))[:twitter] | |
c.consumer_key = config[:consumer_key] | |
c.consumer_secret = config[:consumer_secret] | |
c.oauth_token = config[:oauth_token] | |
c.oauth_token_secret = config[:oauth_token_secret] | |
end | |
@client = Twitter::Client.new | |
end |
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
:twitter: | |
:consumer_key: CONSUMER_KEY | |
:consumer_secret: CONSUMER_SECRET | |
:oauth_token: OAUTH_TOKEN | |
:oauth_token_secret: OAUTH_TOKEN_SECRET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment