简体   繁体   English

如何阻止Twitter时间轴小部件轮询?

[英]How to stop Twitter Timeline Widget from Polling?

I'm using the Twitter embedded Timeline Widget on the login page for a single-page Backbone application. 我将登录页面上的Twitter嵌入式时间轴小部件用于单页Backbone应用程序。 When the user logins in, I change the page via Backbone routing and the Twitter widget is no longer displayed. 当用户登录时,我通过骨干网路由更改了页面,并且不再显示Twitter小部件。 However, if you look at the Network panel of the browser developer tools, there are requests to http://syndication.twimg.com/widgets/timelines/paged/ ... every 15 seconds or so. 但是,如果您查看浏览器开发人员工具的“网络”面板,则会每隔15秒左右请求一次http://syndication.twimg.com/widgets/timelines/paged/ ...。 How can I stop these requests? 如何停止这些请求?

If I delete window.twittr , I get 6 "Uncaught ReferenceError: twttr is not defined" errors from timeout callbacks...which works, but doesn't seem very clean. 如果delete window.twittr ,则会从超时回调中收到6个“ Uncaught ReferenceError:未定义twttr”错误……可以,但是看起来不是很干净。 Is there a better way? 有没有更好的办法?

I believe setting a Tweet limit could be an option. 我认为可以设置Tweet limit

Tweet limit: To fix the size of a timeline to a preset number of Tweets, use the data-tweet-limit="5" attribute with any value between 1 and 20 Tweets. The timeline will render the specified number of Tweets from the timeline, expanding the height of the widget to display all Tweets without scrolling. Tweet限制: To fix the size of a timeline to a preset number of Tweets, use the data-tweet-limit =“ 5”属性 with any value between 1 and 20 Tweets. The timeline will render the specified number of Tweets from the timeline, expanding the height of the widget to display all Tweets without scrolling. 属性的 with any value between 1 and 20 Tweets. The timeline will render the specified number of Tweets from the timeline, expanding the height of the widget to display all Tweets without scrolling. with any value between 1 and 20 Tweets. The timeline will render the specified number of Tweets from the timeline, expanding the height of the widget to display all Tweets without scrolling. Since the widget is of a fixed size, it will not poll for updates when using this option. 由于小部件的大小固定,因此使用此选项时将不会轮询更新。

https://dev.twitter.com/docs/embedded-timelines https://dev.twitter.com/docs/embedded-timelines

eg 例如

<a class="twitter-timeline" href="https://twitter.com/twitterapi" data-widget-id="YOUR-WIDGET-ID-HERE" data-chrome="nofooter" data-tweet-limit="3">Tweets by @twitterapi</a>

And then if desired you could update your widgets manually, by removing them reinserting the html then calling. 然后,如果需要,您可以手动删除小部件,方法是先删除小部件,然后重新插入html,然后调用。

twttr.widgets.load()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM