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

1 view
Skip to first unread message

shyam khadka

unread,
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 = 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

SP

unread,
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:
http://groups.google.com/group/twitter4r-users/browse_thread/thread/4e266946b4dcaf29/ba4bd94b79a886e7?lnk=gst&q=exceptions#ba4bd94b79a886e7

Susan
Reply all
Reply to author
Forward
0 new messages