我能够将twitter gem集成到我的rails应用程序中,但有时它的工作原理和大部分时间都会给出这个错误。以下是关于这个奇怪错误的服务器响应(框架跟踪)的片段。
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'
答案 0 :(得分:0)
如Alexbhandari的评论所述,Twitter的API被限制
为了帮助SO社区正确诊断和诊断修复错误,建议你给出一些关于错误形成的背景信息(当它显示时,我会尝试拉/推什么数据,错误显示你的应用正在做什么)
为了帮助你,你可能会受益匪浅:
Twitter JS Widget
我们遇到了类似的问题经过大量挖掘后,我们发现通过API调用数据是有限的,但通过HTTP调用数据则不然。这就是他们如何自由分发他们的JS小部件,让他们在数百万个网络属性上运行
这意味着如果您想要不间断地显示推文等,您最好实现自己的JS小部件。您可以在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;
};
});
这是 TwitterFetcher JS插件的实现,您必须将其包含在JS管道中
希望这有帮助吗?
答案 1 :(得分:0)
twitter.rb已存在于twitter gem中。尝试将config / initializers / twitter.rb更改为其他内容。