Can't tweet to no. of accounts at a time

1 view
Skip to first unread message

shyam khadka

Nov 10, 2009, 12:21:31 AM11/10/09
to twitter4r-users
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 = => account[0], :password =>

# post it to twitter
new_message = client.status(:post, " My
twitter post")

puts "Posted to #{account[0]}"
rescue Exception => e
puts :text=>"There was an error with your request- #{e}"
Here twitter_accounts is an array containing array of twitter username/
password pair like this:
twitter_accounts = [['twitter_name1','twitter_password1'],
Suggestions are welcome


Nov 10, 2009, 7:59:25 AM11/10/09
to twitter4r-users
Hi Shyam,

This appears to be more a basic Ruby programming question regarding
how to do exception handling and has already been answered in a
previous thread on this very Google Group:

Reply all
Reply to author
0 new messages