Php – Twitter status stopped working

PHPtwitter

Hi I've been using this code to display my status on a site

$doc = new DOMDocument();

# load the RSS
if($doc->load('http://twitter.com/statuses/user_timeline/12345678.rss')) {

# number of tweets to display.  20 is the maximum
$max_tweets = 3;    

$i = 1;
foreach ($doc->getElementsByTagName('item') as $node) {
# fetch the title from the RSS feed. 
$tweet = $node->getElementsByTagName('title')->item(0)->nodeValue;
$date = $node->getElementsByTagName('pubDate')->item(0)->nodeValue;
$link = $node->getElementsByTagName('link')->item(0)->nodeValue;

# the title of each tweet starts with "username: " which I want to remove
$tweet = substr($tweet, stripos($tweet, ':') + 1);
if(preg_match('/^\s*@([0-9a-zA-Z]+)/', $tweet))
    continue;
$date = date("dS F Y", strtotime($date));  

# Turn URLs into links
$tweet = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', 
'<a href="$1">$1</a>', $tweet);

# Turn @replies into links
#$tweet = preg_replace("/@([0-9a-zA-Z]+)/", 
#"<a href=\"http://twitter.com/$1\">@$1</a>", 
#$tweet);

# Turn & into &amp;     
$tweet = preg_replace('@&@', 
'&amp;', $tweet);

if($i%2 == 0) {
echo "<div class=\"three-col center\"><p>". $tweet  . "<br /><span class=\"quiet\"><a href=\"". $link ."\">". $date ."</a></span></p></div>\n";
}
else {
echo "<div class=\"three-col\"><p>". $tweet  . "<br /><span class=\"quiet\"><a href=\"". $link ."\">". $date ."</a></span></p></div>\n";
}

if($i++ >= $max_tweets) break;
}
}

Its been working fine until recently! these are the errors I'm seeing…

Warning: DOMDocument::load() [domdocument.load]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution on line 5

Warning: DOMDocument::load(http://twitter.com/statuses/user_timeline/12345678.rss) [domdocument.load]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution on line 5

Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "http://twitter.com/statuses/user_timeline/12345678.rss" on line 5

Yours thoughts are much appreciated

Thanks

Best Answer

Warning: DOMDocument::load() [domdocument.load]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution on line 5

This sounds as if your server cannot find twitter.com Maybe some DNS problem? Can you reach twitter.com from your server using other tools, e.g. wget or curl?

Related Topic