All of a sudden, my Twitter widget on my website is not showing any tweets. I've checked my console log and it's returning a 400 bad request error. This was working fine only an hour ago! I have been working on this page today and probably refreshed the page 30+ times. I wonder if that had anything to do with it.

I've read other SO questions related to the same problem and some say it's a problem Twitter's end and you just have to wait. This is an issue for me. I've now got a big blank space where the widget should sit, and looks darn ugly and unprofessional!

Is there any way to detect this error and show a polite message in its place "Sorry, Twitter widget is ** crap and can't be loaded."? Or can you give me any more information?

<script charset="utf-8" src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 10,
  interval: 30000,
  width: 270,
  height: 250,
  theme: {
    shell: {
      background: '#111111', color: '#B000BB'
    },
    tweets: {
      background: '#111111', color: '#999999', links: '#faadfa'
    }
  },
  features: {
    scrollbar: true, loop: false, live: true, behavior: 'all'
  }
}).render().setUser('myClientsTwitterUsername').start();
</script>
有帮助吗?

解决方案

I've just found the answer, so hopefully it will help others.

Apparently the Twitter widget I'm using does not use Twitter's API, thus, I'm limited to 150 requests per hour, per IP address. With the work I did on this page today, refreshing the page 30-40 times, and the widget updating every 30 seconds, it seems I have used all 150 requests and have been barred from further requests until the limit refreshes. I checked this by loading my webpage on my iPad (which uses a different IP address/network) and the widget seems fine. I also waited 1 hour and the widget came back to life on the affected network/ip.

So, I'd better start using the proper Twitter API widget.

Hope this helps somebody.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top