Twitter 小部件并不总是填充
我正在我的网站上显示来自他们的提要小部件的 Twitter 提要。有时小部件喜欢不显示任何信息。我认为这是因为 API 超载。无论如何,如果 Twitter 无法加载我的提要,是否有任何已知的方法可以显示错误消息?还有其他人遇到过这些问题吗?
I am displaying a Twitter feed from their feed widget on my website. Sometimes the widget likes to not display any information. I figure this is because the API is overloaded. Regardless, is there any known way to display an error message in the event that Twitter can't load my feed? Has anybody else experienced these issues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先使用适合您操作系统的http记录代理(如果您在Windows上,Fiddler2非常棒),按F5移动页面,直到出现错误。
过滤主机 widgets.twimg.com 或 api.twitter.com 的日志...这会诊断故障点,因为:
为了检测 javascript 中的 1,您可以使用超时来检测加载失败,然后 onload 检查它是否已加载(简单的检查是 window.twttr 是否存在 - 但这不是一个很好的测试,因为它是在 javascript 顶部设置的,因此仅确认 javascript 语法有效并开始运行)。 (可能需要 onreadystate 来检测 IE 的负载?)
为了检测 2,使用调试器运行页面。
对于 3,从快速查看代码来看,代码看起来像是重试对 twitter api 的请求(您可能想查看 api 的配置设置),并且看起来有 api 变量来检查一切是否正在运行,例如
TWTR.Widget.isLoaded
_isRunning
和_hasOfficiallyStarted
。Firstly use a suitable http recording proxy for your OS (Fiddler2 is fantastic if you are on windows), shift F5 the page until you get the fault.
Filter the log for hosts widgets.twimg.com or api.twitter.com... This diagnoses the failure point because:
For detecting 1 in javascript, you can detect the failure to load by using a timeout, and onload check that it loaded (simple check is that window.twttr exists - however not a great test because that gets set at top of javascript, so only confirms that javascript syntax was valid and started running). (Might need onreadystate to detect load for IE?)
For detecting 2, run page with debugger.
For 3, from a quick look at the code, looks like the code retries requests to the twitter api (you might want to look ath the configuration settings for the api) and it looks like there are api variables to check if everything is running e.g.
TWTR.Widget.isLoaded
_isRunning
and_hasOfficiallyStarted
.