Created
January 8, 2009 06:25
-
-
Save jaigouk/44612 to your computer and use it in GitHub Desktop.
This file contains 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
#create tweets | |
#Since twitter API does not provide unique message check, | |
#I had to build db to validiate it. | |
def bark(tweet) | |
@tweet = Tweet.new(tweet) | |
if @tweet.save | |
############ RUN LATER BLOCK ################ | |
run_later do | |
begin | |
post(tweet) | |
rescue Twitter::RESTError => re | |
unless re.code == "403" | |
puts re | |
end | |
end #begin-rescue end | |
end #run_later end | |
############ RUN LATER BLOCK ################ | |
else | |
puts "failed to save them" | |
end | |
end | |
def post(tweet) | |
sleep(15) # sleep. because of twitter api limit | |
@poster = tweet[:message] + tweet[:name] +", " + tweet[:date] +"ago)" + tweet[:link] | |
status =@post_client.status(:post, @poster) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment