Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 344515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:59:52+00:00 2026-05-12T10:59:52+00:00

Every time I try to post to twitter in my rails app, the first

  • 0

Every time I try to post to twitter in my rails app, the first post
fails. I will explain the issue further after I show a quick example.
Here is a live example from the console (with sensitive stuff edited):

>> u = User.find(7)
=> #<User id: 7, login: "corgan1003@gmail.com", email:
"corgan1003@gmail.com", crypted_password: "stuff", salt: "stuff",
twitter_token: "some_twitter_token", twitter_secret:
"some_twitter_secret", twitter_sn: "some_twitter_sn">

>> u.twitter_client
=> #<Twitter::Base:0x7f11672957a0 @client=#<Twitter::OAuth:
0x7f1167295728 @csecret="some_c_secret", @ctoken="some_c_token",
@asecret="some_a_secret", @consumer_options={},
@atoken="some_a_token">>

>> u.twitter_client.update("Hello World")
=> false

>> u.twitter_client
=> #<Twitter::Base:0x7f11672957a0 @client=#<Twitter::OAuth:
0x7f1167295728 @csecret="some_c_secret", @consumer=#<OAuth::Consumer:
0x7f1167290bd8 @uri=#<URI::HTTP:0x3f88b3948330 URL:http://
twitter.com>, @options={:access_token_path=>"/oauth/
access_token", :site=>"http://
twitter.com", :oauth_version=>"1.0", :scheme=>:header, :request_token_path=>"/
oauth/request_token", :signature_method=>"HMAC-
SHA1", :http_method=>:post, :authorize_path=>"/oauth/authorize"},
@http=#<Net::HTTP twitter.com:80 open=false>, @secret="secret",
@key="key">, @access_token=#<OAuth::AccessToken:0x7f1167290c78
@consumer=#<OAuth::Consumer:0x7f1167290bd8 @uri=#<URI::HTTP:
0x3f88b3948330 URL:http://twitter.com>, @options=
{:access_token_path=>"/oauth/access_token", :site=>"http://
twitter.com", :oauth_version=>"1.0", :scheme=>:header, :request_token_path=>"/
oauth/request_token", :signature_method=>"HMAC-
SHA1", :http_method=>:post, :authorize_path=>"/oauth/authorize"},
@http=#<Net::HTTP twitter.com:80 open=false>, @secret="secret",
@key="key">, @token="token", @response=#<Net::HTTPRequestTimeOut 408
Request Timeout readbody=true>, @secret="secret">, @ctoken="ctoken",
@asecret="asecret", @consumer_options={}, @atoken="atoken">>

>> u.twitter_client.update("Hello World")
=> <Mash created_at="Thu Sep 03 01:38:21 +0000 2009" favorited=false
id=3724099662 in_reply_to_screen_name=nil in_reply_to_status_id=nil
in_reply_to_user_id=nil source="<a href=\"http://www.url.com\" rel=
\"nofollow\">MyApp</a>" text="Hello World" truncated=false user=<Mash
created_at="Tue Aug 11 19:47:26 +0000 2009" description=nil
favourites_count=0 followers_count=4 following=false friends_count=21
id=64803633 location=nil name="some name" notifications=false
profile_background_color="9ae4e8" profile_background_image_url="http://
s.twimg.com/a/1251923748/images/themes/theme1/bg.gif"
profile_background_tile=false profile_image_url="http://s.twimg.com/a/
1251923748/images/default_profile_normal.png"
profile_link_color="0000ff" profile_sidebar_border_color="87bc44"
profile_sidebar_fill_color="e0ff92" profile_text_color="000000"
protected=false screen_name="screen_name" statuses_count=4
time_zone=nil url=nil utc_offset=nil verified=false>>

>> u.twitter_client
=> #<Twitter::Base:0x7f11672957a0 @client=#<Twitter::OAuth:
0x7f1167295728 @csecret="csecret", @consumer=#<OAuth::Consumer:
0x7f1167290bd8 @uri=#<URI::HTTP:0x3f88b3948330 URL:http://
twitter.com>, @options={:access_token_path=>"/oauth/
access_token", :site=>"http://
twitter.com", :oauth_version=>"1.0", :scheme=>:header, :request_token_path=>"/
oauth/request_token", :signature_method=>"HMAC-
SHA1", :http_method=>:post, :authorize_path=>"/oauth/authorize"},
@http=#<Net::HTTP twitter.com:80 open=false>, @secret="secret",
@key="key">, @access_token=#<OAuth::AccessToken:0x7f1167290c78
@consumer=#<OAuth::Consumer:0x7f1167290bd8 @uri=#<URI::HTTP:
0x3f88b3948330 URL:http://twitter.com>, @options=
{:access_token_path=>"/oauth/access_token", :site=>"http://
twitter.com", :oauth_version=>"1.0", :scheme=>:header, :request_token_path=>"/
oauth/request_token", :signature_method=>"HMAC-
SHA1", :http_method=>:post, :authorize_path=>"/oauth/authorize"},
@http=#<Net::HTTP twitter.com:80 open=false>, @secret="secret",
@key="key">, @token="token", @response=#<Net::HTTPOK 200 OK
readbody=true>, @secret="secret">, @ctoken="ctoken",
@asecret="asecret", @consumer_options={}, @atoken="atoken">>

It’s obvious that doing u.twitter_client the first time is not
setting the client properly as @consumer is not set and the first time
I do u.twitter_client.update(“Hello World”), if i look at the client
after that I see the 408 request time out issue which is really
strange to me. Does anyone know how I can fix this? I am including
my functions below that the above example used.

def twitter_oauth
   @oauth ||= Twitter::OAuth.new(ConsumerConfig['twitter_token'],
ConsumerConfig['twitter_secret'])
end

def twitter_client
   @client ||= begin
     twitter_oauth.authorize_from_access(twitter_token,
twitter_secret)
     Twitter::Base.new(twitter_oauth)
   end
end

Update
I should also note that this issue only occurs in my production environment. This process would tweet successfully in my development environment.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:59:52+00:00Added an answer on May 12, 2026 at 10:59 am

    Do you need to change the credentials for your production environment? When you setup your application on the Twitter site now you specify what URL you want it to return to and it skips whatever URL you pass in programatically as a return (security feature).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Every time I try to add my var of record it will not run
Every time I try this the browser raises an error app.py import web urls
Every time try to set the value of any variable in my model object,
Every time I try to run a small application that uses a Derby DB
Every time I try to do something seemingly-simple in CSS, it doesn't work. I
For some reason every time I try to count the number of rows in
I am getting a conversion error every time I try to submit a date
I have one particular FLA that is crashing every time I try to compile
I'm using VS2008 (with windows XP). Every time I try to run a unit
I have a Visual Studio 2005 solution. Every time I try to run the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.