Multiple tweets from one api status update post


I am working on an app that is posts a status update every day to each of 50 accounts (one for each state – @xx_prays). A read/write app was created for each account and the state, consumer_key, consumer_secret, oauth_token, and oauth_secret keys are in a csv file. I am experiencing a strange result. The tweet to most accounts is working properly. However I have at least one account (@nm_prays) that consistently tweets 25 of the 50 status updates but I am thinking that my code does not cause this. I have looked at my code over and over and I cannot discern how this is happening. Here is my code:

require 'csv’
require ‘oauth’

def prepare_access_token(consumer_key, consumer_secret, oauth_token, oauth_token_secret)
consumer =, consumer_secret, { :site => “”, :scheme => :header })
token_hash = { :oauth_token => oauth_token, :oauth_token_secret => oauth_token_secret }
OAuth::AccessToken.from_hash(consumer, token_hash )

CSV.foreach(“twitter_states_credentials.csv”) do |row|
st=row[0].downcase # The 2 letter state abbreviation
update_hash = { ‘status’ => ‘’+st+’ Please pray for: [So and So]’ }
access_token = prepare_access_token(row[1], row[2], row[3], row[4])‘’, update_hash, { ‘Accept’ => ‘application/xml’ })

Any help / thoughts / questions would be most appreciated. Thank you!


Is it possible your CSV file has duplicate entries?

By the way, your Accept header is a little strange in this context – the API only returns plain text, HTML, and JSON – you might want to change that Accept to “application/json” – though that point is unlikely related to your problems.


Thanks for replying. Good pointer about accepting json. Yes, the csv file is correct with one unique entry for each one of the 50 state twitter accounts.