【问题标题】:PHP XML feed usage from Twitter来自 Twitter 的 PHP XML 提要使用情况
【发布时间】: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 行

【问题讨论】:

标签: php xml twitter


【解决方案1】:

您可以尝试使用 DOMDocument->load( $url )。 Twitter 提要的 URL 也可以在没有 SSL 的情况下使用,如果 SSL 让您感到痛苦并且您不需要安全版本,请尝试使用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-16
    • 2012-04-27
    • 1970-01-01
    • 2012-03-28
    • 2016-08-26
    相关资源
    最近更新 更多