Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
46 lines (39 sloc) 1.51 KB
require 'rubygems'
require 'sinatra'
require 'yaml'
require 'twitter_oauth'
require 'sinatra/r18n'
set :default_locale, 'en'
set :translations, './locales'
before do
session[:locale] = params[:locale] unless params[:locale].nil?
set :locale, session[:locale]
end
configure do
enable :sessions
end
get "/" do
erb :index
end
get "/connect" do
client = TwitterOAuth::Client.new(:consumer_key => ENV["CONSUMER_KEY"], :consumer_secret => ENV["CONSUMER_SECRET"])
request_token = client.request_token(:oauth_callback => ENV["CALLBACK_URL"])
session[:request_token] = request_token.token
session[:request_token_secret] = request_token.secret
redirect request_token.authorize_url
end
get "/oauth" do
session[:oauth_verifier] = params[:oauth_verifier]
client = TwitterOAuth::Client.new(:consumer_key => ENV["CONSUMER_KEY"], :consumer_secret => ENV["CONSUMER_SECRET"])
session[:access_token] = client.authorize(session[:request_token], session[:request_token_secret], :oauth_verifier => session[:oauth_verifier])
@fakes = (client.info["followers_count"].to_i/12).to_i
erb :show
end
get "/tweet" do
client = TwitterOAuth::Client.new(:consumer_key => ENV["CONSUMER_KEY"], :consumer_secret => ENV["CONSUMER_SECRET"])
session[:access_token] = client.authorize(session[:request_token], session[:request_token_secret], :oauth_verifier => session[:oauth_verifier])
@fakes = (client.info["followers_count"].to_i/12).to_i
status = t.message(@fakes)
client.update(status) if client.authorized?
redirect "/?s=ok"
end
You can’t perform that action at this time.