来自 Twitter 的 PHP XML 提要使用情况
Posted
技术标签:
【中文标题】来自 Twitter 的 PHP XML 提要使用情况【英文标题】:PHP XML feed usage from Twitter 【发布时间】:2012-01-10 18:00:20 【问题描述】:以下代码应从 Twitter 获取 xml 提要并回显结果。
<?php
$xml = simplexml_load_file('https://api.twitter.com/1/statuses/user_timeline/QuiteCheesedOff.xml?count=6');
$tweets = $xml->xpath("/statuses/status");
foreach($tweets as $tweet)
$text = $tweet->text;
$date = $tweet->created_at;
echo '<div>' . $text . '</div>' . '<b>' . $date . '</b>';
?>
而是返回 this。
警告: simplexml_load_file(https://api.twitter.com/1/statuses/user_timeline/QuiteCheesedOff.xml?count=6) [function.simplexml-load-file]:无法打开流:HTTP 请求 失败的! HTTP/1.0 400 错误请求 /home/divethe1/public_html/robin-knight.com/wp-content/themes/RIKsoft/index.php 在第 142 行
【问题讨论】:
可能与限速有关:dev.twitter.com/docs/rate-limiting 它现在正在工作,原因不明 由于未知原因无法再次工作 【参考方案1】:您可以尝试使用 DOMDocument->load( $url )。 Twitter 提要的 URL 也可以在没有 SSL 的情况下使用,如果 SSL 让您感到痛苦并且您不需要安全版本,请尝试使用。
【讨论】:
以上是关于来自 Twitter 的 PHP XML 提要使用情况的主要内容,如果未能解决你的问题,请参考以下文章