Skip to content

Instantly share code, notes, and snippets.

@jaigouk
Created January 8, 2009 06:25
Show Gist options
  • Save jaigouk/44612 to your computer and use it in GitHub Desktop.
Save jaigouk/44612 to your computer and use it in GitHub Desktop.
#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