twitter gem and a partial added to embed tweets about a conference and new layout added for conference info screen
This commit is contained in:
parent
febd3451ad
commit
f29a15b8e4
11 changed files with 216 additions and 28 deletions
25
app/models/twitter_wrapper.rb
Normal file
25
app/models/twitter_wrapper.rb
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
class TwitterWrapper
|
||||
attr_accessor :client
|
||||
|
||||
def initialize
|
||||
@client = Twitter::REST::Client.new do |config|
|
||||
config.consumer_key = ENV["OSEM_TWITTER_CONSUMER_KEY"]
|
||||
config.consumer_secret = ENV["OSEM_TWITTER_CONSUMER_SECRET"]
|
||||
config.access_token = ENV["OSEM_TWITTER_ACCESS_TOKEN"]
|
||||
config.access_token_secret = ENV["OSEM_TWITTER_ACCESS_TOKEN_SECRET"]
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
#Fetches tweets from twitter api based on search_term and no_of_tweets
|
||||
#
|
||||
def search_tweets(no_of_tweets, search_term)
|
||||
begin
|
||||
@client.search(search_term, result_type: "recent").take(no_of_tweets).collect
|
||||
rescue Twitter::Error::TooManyRequests => error
|
||||
sleep error.rate_limit.reset_in + 1
|
||||
retry
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue