2011-12-01 79 views
0

以下代碼應該採用來自Twitter的xml提要並回顯結果。來自Twitter的PHP 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>'; 
} 

?> 

相反,它返回這個。

警告: 使用simplexml_load_file(https://api.twitter.com/1/statuses/user_timeline/QuiteCheesedOff.xml?count=6) [function.simplexml負荷文件]:未能打開流:HTTP請求 失敗! HTTP/1.0 400 /home/divethe1/public_html/robin-knight.com/wp-content/themes/RIKsoft/index.php 錯誤的請求上線142

+1

它可能與速率限制有關:https://dev.twitter.com/docs/rate-limiting –

+0

IT的工作原因不明原因 –

+0

由於未知原因,IT無法再工作 –

回答

0

您可以嘗試使用上一層>負荷($ url)。 Twitter提要的URL也可以在沒有SSL的情況下使用,如果SSL給您帶來悲傷,並且您不需要安全版本,請嘗試使用。