For almost a year my tweets have been displaying fine on my Wordpress blog without any issue what-so-ever, and yesterday morning my regular tweet at 9:00am appeared on the blog at 9:04 (the tweet’s time stamp indicated it was 4 mins old). My blog has a plugin to retrieve the tweets every 30 minutes however 30 mins later it started reporting an error while retrieving the tweets, which still remains.
I traced the problem in the plugin code to the line of code that calls the WordPress function to fetch the feed:
$feed = fetch_feed(‘http://twitter.com/statuses/user_timeline.rss?screen_name=’ . $username);
where $username is my twitter name. Nothing is returned by fetch_feed and thus $feed is an invalid object. If I try and fetch any twitter name (not just my own) they also fail, however if I change it to fetch other RSS feeds (not twitter) there is no error and they are retrieved and displayed (although somewhat truncated). For example, I’ve tried the following without error:
$feed = fetch_feed(‘http://www.theglobeandmail.com/?service=rss’);
$feed = fetch_feed(‘http://www.nature.com/nature/current_issue/rss’);
$feed = fetch_feed(‘http://www.theismaili.org/rss.xml’);
The plugin developer advised me the following:
The fetch_feed function is essentially only a
wrapper for the SimplePie library that comes with WordPress, see here:
http://codex.wordpress.org/Function_Reference/fetch_feed
I think the best you can do is checking if the SimplePie object has
any error message and what the error is. Just like here:
http://simplepie.org/wiki/reference/simplepie/error
I tried the following code from simplepie.org
$feed = new SimplePie();
$feed->set_feed_url(‘http://twitter.com/statuses/user_timeline.rss?screen_name=’ . $username’);
$feed->init();
$feed->handle_content_type();
if ($feed->error())
{
echo $feed->error();
}
And it reported the error “URL error 28: connect() timed out!”. I have noticed that while the twitter plugin is active, pages are taking a long time to load (no doubt due to this time-out). If I deactivate the plugin, pages load instantly.
I tried the following twitter plugins for Wordpress and they all gave the same problems too:
One of these allowed me to extend the time-out period but it made no difference.
I upgraded a test version of the blog I have from Wordpress 3.01 (what I’m using) to version 3.2.1 (the latest version) and I’m still getting the error.
So since the only time I get the error is with twitter RSS feeds, regardless of which Wordpress version or twitter plugin I use, and don’t get errors with any other RSS feeds, it would seem something subtle has changed at twitter, even though twitter RSS feeds work find my browser and other RSS applications, and many other Wordpress blogs.
Any help would be much appreciated.