I am using twitter 4r gem in my rails site in which the site asks for
users' twitter name and password so that a bible verse is posted every
day in their twitter post.
The problem is that if a user supplies wrong twitter user name/
password pair, the rest of the accounts do not get posted.The program
stuck with 'HTTP 401: Unauthorized at error'.
So how can i suppress this error so that the program continues on
tweeting rest of the accounts leaving invalid twitter account intact?
My rake file is like this:
twitter_accounts.each do |account|
# log into the twitter account
client = Twitter::Client.new(:login => account[0], :password =>
account[1])
begin
# post it to twitter
new_message = client.status(:post, "
http://mysite.com My
twitter post")
puts "Posted to #{account[0]}"
rescue Exception => e
puts :text=>"There was an error with your request- #{e}"
return
end
end
Here twitter_accounts is an array containing array of twitter username/
password pair like this:
twitter_accounts = [['twitter_name1','twitter_password1'],
['twitter_name2','twitter_password2'],
['twitter_name3','twitter_password3']]
Suggestions are welcome