Skip to content

Instantly share code, notes, and snippets.

@shuntaroy
Last active Dec 2, 2018
Embed
What would you like to do?
Assume keys are stored into environment variables
import os
import tweepy
consumer_key = os.environ['TWITTER_CONSUMER_KEY']
consumer_secret = os.environ['TWITTER_CONSUMER_SECRET']
access_token = os.environ['TWITTER_ACCESS_TOKEN']
access_token_secret = os.environ['TWITTER_ACCESS_TOKEN_SECRET']
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
client = tweepy.API(auth)
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV["TWITTER_CONSUMER_KEY"]
config.consumer_secret = ENV["TWITTER_CONSUMER_SECRET"]
config.access_token = ENV["TWITTER_ACCESS_TOKEN"]
config.access_token_secret = ENV["TWITTER_ACCESS_TOKEN_SECRET"]
end
import os
from twython import Twython
twitter = Twython(
os.environ["TWITTER_ACCESS_TOKEN"],
access_token=os.environ["TWITTER_BEARER_TOKEN"]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment