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 = OAuth::Consumer.new(consumer_key, consumer_secret, { :site => “https://api.twitter.com”, :scheme => :header })
token_hash = { :oauth_token => oauth_token, :oauth_token_secret => oauth_token_secret }
OAuth::AccessToken.from_hash(consumer, token_hash )
end
CSV.foreach(“twitter_states_credentials.csv”) do |row|
st=row[0].downcase # The 2 letter state abbreviation
update_hash = { ‘status’ => ‘http://pray1tim2.org/s/’+st+’ Please pray for: [So and So]’ }
access_token = prepare_access_token(row[1], row[2], row[3], row[4])
access_token.post(‘https://api.twitter.com/1.1/statuses/update.json’, update_hash, { ‘Accept’ => ‘application/xml’ })
end
Any help / thoughts / questions would be most appreciated. Thank you!