0

I am able to integrate the twitter gem into my rails application, but sometimes its works and mostly time it gives this error. Here is the snippet of my server response(framework trace) on this weird error.

twitter (5.4.1) lib/twitter/rest/client.rb:143:in `rescue in request'
twitter (5.4.1) lib/twitter/rest/client.rb:131:in `request'
twitter (5.4.1) lib/twitter/rest/client.rb:97:in `get'
twitter (5.4.1) lib/twitter/search_results.rb:68:in `fetch_next_page'
twitter (5.4.1) lib/twitter/enumerable.rb:13:in `each'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.13) lib/active_support/callbacks.rb:414:in             
`_run__1064161776__process_action__779617573__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in  
`_run_process_action_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in  
process_action'   
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in 
`instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in   
`process_action'
actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in    
`process_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process' 
actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
live_alone
  • 159
  • 1
  • 11
  • can't make much of the error, but twitter limits the number of queries you can make and that might be why it sometimes works and sometimes doesn't. https://dev.twitter.com/docs/rate-limiting/1.1 – alexbhandari Dec 31 '13 at 03:14
  • I am continuously checking the rate limit, there is no problem of rate limit. – live_alone Jan 03 '14 at 06:45

2 Answers2

0

As mentioned in Alexbhandari's comment, Twitter's API is throttled

In order to help the SO community properly diagnose & fix the error, it's recommended you give some context as to how the error is forming (I.E when it shows, what data you're trying to pull / push, what your app is doing when the error shows)

To help you out a little, there's something you might benefit from:


Twitter JS Widget

We had a similar issue with the Twitter gem

After lots of digging, we found that calling data through the API is limited, but calling data through HTTP is not. This is how they can freely distribute their JS widgets, and have them run on millions of web properties

This means if you want uninterrupted display of tweets, etc, you'd be best implementing your own JS widget. You can see an example at the bottom of one of our dev sites:

//app/assets/javascripts/application.js
//Footer Twitter Feed (via extra/TwitterFetch)
$(document).ready(function(){
    twitterFetcher.fetch('385319530999738368', 'twitter_feed', 3, true, true, true, '', false, handleTweets, false);
    function handleTweets(tweets){
        var x = tweets.length;
        var n = 0;
        var element = document.getElementById('twitter_feed');
        var html = '<ul>';
        while(n < x) {
            html += '<li>' + tweets[n] + '</li>';
            n++;
        }
        html += '</ul>';
        element.innerHTML = html;
    };
});

This is an implementation of the TwitterFetcher JS plugin, which you've got to include in your JS pipeline

Hope this helps?

Richard Peck
  • 76,116
  • 9
  • 93
  • 147
  • I don't want to display the tweets on my website, actually I want to index them in the database(using search api), so that analysis part can be done. – live_alone Jan 03 '14 at 06:39
0

twitter.rb is already existing in twitter gem. Try changing your config/initializers/twitter.rb to something else.

usama kabel
  • 11
  • 1
  • 4