Twitter状态停止了工作

时间:2009-09-28 10:02:33

标签: php twitter

您好我一直在使用此代码在网站上显示我的状态

$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;
}
}

直到最近一直工作正常!这些是我看到的错误......

警告: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 failed:第5行名称解析暂时失败

警告:DOMDocument :: load()[domdocument.load]:I / O警告:无法在第5行加载外部实体“http://twitter.com/statuses/user_timeline/12345678.rss

非常感谢您的想法

谢谢

1 个答案:

答案 0 :(得分:0)

  

警告:DOMDocument :: load()[domdocument.load]:php_network_getaddresses:getaddrinfo失败:第5行名称解析暂时失败

这听起来好像您的服务器找不到twitter.com 也许有些DNS问题?您可以使用其他工具从服务器访问twitter.com,例如wget或curl?