您好,我一直在使用这个代码来显示我在一个网站上的状态
$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 &
$tweet = preg_replace('@&@',
'&', $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;
}
}直到最近,它一直运行得很好!这些是我看到的错误...
警告: DOMDocument::load() domdocument.load: php_network_getaddresses: getaddrinfo失败:第5行的名称解析暂时失败
警告: DOMDocument::load(http://twitter.com/statuses/user_timeline/12345678.rss) domdocument.load:无法打开流: php_network_getaddresses: getaddrinfo失败:第5行的名称解析暂时失败
警告: DOMDocument:: load () domdocument.load: I/O警告:无法在第5行加载外部实体“http://twitter.com/statuses/user_timeline/12345678.rss
非常感谢您的想法
谢谢
发布于 2009-09-28 10:06:02
警告: DOMDocument::load() domdocument.load: php_network_getaddresses: getaddrinfo失败:第5行的名称解析暂时失败
这听起来好像你的服务器找不到twitter.com,也许是一些DNS问题?您可以使用其他工具从您的服务器访问twitter.com吗?
https://stackoverflow.com/questions/1486274
复制相似问题