Twitter4r on Rails 2.3.3

3 views
Skip to first unread message

Sérgio Santos

unread,
Aug 17, 2009, 9:19:50 AM8/17/09
to twitter4r-users
I've been trying to make an rails application work with Twitter4r, on
rails version 2.3.3. But I'm in a strange situation.

If I try the following code at the script/console, it works perfectly:

client = TweetApp::Client.new( :login => 'username', :password
=> 'XXX' )
user = client.my(:info)

But through the webserver, it gives me an Twitter::RESTError 404 Not
Found. Any idea what it might be?

Twitter4r 0.3.1 is freezed on my application and mine environment.rb
has:

config.gem 'twitter4r', :lib => 'twitter', :version => '~> 0.3.0'

...and...

module TweetApp
ENV["RAILS_ENV"] ||= "development" # assume development environment
if no RAILS_ENV set.
Client = Twitter::Client
end


Thanks.

Susan Potter

unread,
Aug 17, 2009, 10:38:48 AM8/17/09
to twitter4r-users
Sérgio,

Could you try the following:

Use the following in your environment.rb and unfreeze twitter4r 0.3.1
from your application (I have seen freezing issues before):
config.gem 'twitter4r', :lib => 'twitter', :version => '>=0.3.1'

If the above modification doesn't change anything try removing the
above gem dependency from your environment.rb completely and then
freezing Twitter4r 0.3.1 back again into your application. I suspect
one of these things is conflicting since the versions don't exactly
match.

Also please make sure that you have a config/twitter.yml (if and only
if you are using Twitter::Client.from_config instead of
Twitter::Client.new) that has the following structure:

development:
login: yourlogin
password: yourpassword
test:
login: yourlogin
password: yourpassword
production:
login: yourlogin
password: yourpassword

If the problem persists please send me the full RESTError backtrace.
Thanks,
Susan

Sérgio Santos

unread,
Aug 17, 2009, 11:46:37 AM8/17/09
to twitter...@googlegroups.com
After testing your suggestions, the problem persists.

And I need to use Client.new since I'm expecting the login and password from a web form.

The full RESTError:

Twitter::RESTError (Not Found):
  vendor/gems/twitter4r-0.3.1/lib/twitter/client/base.rb:39:in `raise_rest_error'
  vendor/gems/twitter4r-0.3.1/lib/twitter/client/base.rb:44:in `handle_rest_response'
  vendor/gems/twitter4r-0.3.1/lib/twitter/client/base.rb:18:in `http_connect'
  c:/ruby/lib/ruby/1.8/net/http.rb:547:in `start'
  vendor/gems/twitter4r-0.3.1/lib/twitter/client/base.rb:14:in `http_connect'
  vendor/gems/twitter4r-0.3.1/lib/twitter/client/user.rb:61:in `my'
  app/controllers/user_controller.rb:18:in `login'
  c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
  c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
  c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
  c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
  c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
  c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
  -e:2:in `load'

Hope it helps. Thanks,

Sérgio Santos


2009/8/17 Susan Potter <mbbx...@gmail.com>

Filipe Giusti

unread,
Aug 17, 2009, 2:06:52 PM8/17/09
to twitter...@googlegroups.com
Hello,

That's almost the same problem I had.

Twitter changed their API and it broke the gem usage. You can solve it with a small fix. Take a look at the changes I did on http://github.com/filipegiusti/twitter4r/tree/master or wait a little for Susan have a look at my pull request.
:)

--
Filipe Vernetti Giusti

Sérgio Santos

unread,
Aug 17, 2009, 5:04:25 PM8/17/09
to twitter...@googlegroups.com
I had already tested your latest changes, but what puzzles me is that in the script/console works perfectly.

In the webserver the error occurs at "user = client.my(:info)", but the problem seems to have nothing to do with the change related with the other mailing list thread.

Sérgio Santos

2009/8/17 Filipe Giusti <filipe...@gmail.com>

Susan Potter

unread,
Aug 17, 2009, 8:48:31 PM8/17/09
to twitter4r-users
When you run it in the console are you using your username rather than
your email address? If you are relying on user input, it is possible
that the user is using their email address instead of username. Try
in the console to use your email address instead of username to see if
you are successful or not.

Thanks and let us know,
Susan

On Aug 17, 4:04 pm, Sérgio Santos <prann...@gmail.com> wrote:
> I had already tested your latest changes, but what puzzles me is that in the
> script/console works perfectly.
>
> In the webserver the error occurs at "user = client.my(:info)", but the
> problem seems to have nothing to do with the change related with the other
> mailing list thread.
>
> Sérgio Santos
>
> 2009/8/17 Filipe Giusti <filipegiu...@gmail.com>
>
>
>
> > Hello,
>
> > That's almost the same problem I had.
>
> > Twitter changed their API and it broke the gem usage. You can solve it with
> > a small fix. Take a look at the changes I did on
> >http://github.com/filipegiusti/twitter4r/tree/masteror wait a little for
> > Susan have a look at my pull request.
> > :)
>
> > --
> > Filipe Vernetti Giusti
>
> >> 2009/8/17 Susan Potter <mbbx6...@gmail.com>

Sérgio Santos

unread,
Aug 18, 2009, 6:45:05 PM8/18/09
to twitter...@googlegroups.com
It was a mistake I made in mine application. And I didn't notice that the twitter API returned an 404 for an invalid user id, instead of a more useful error, therefore the Not Found message.

Sorry for the trouble and thanks for eveything,

Sérgio Santos

2009/8/18 Susan Potter <mbbx...@gmail.com>
Reply all
Reply to author
Forward
0 new messages