2011-12-01 2 views
0

다음 코드는 xml 피드를 Twitter에서 가져 와서 결과를 표시합니다.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>'; 
} 

?> 

대신이 값을 반환합니다.

경고 : 스트림을 열지 못했습니다 : 은 [function.simplexml-로드 파일] simplexml_load_file (https://api.twitter.com/1/statuses/user_timeline/QuiteCheesedOff.xml?count=6) : HTTP 요청 실패! 라인 /home/divethe1/public_html/robin-knight.com/wp-content/themes/RIKsoft/index.php 에서 HTTP/1.0 400 잘못된 요청 (142)

+1

는 속도 제한과 관련 될 수있다 : https://dev.twitter.com/docs/rate-limiting –

+0

IT는 IT가 알 수없는 이유로 다시 작동하지 않습니다 알 수없는 이유로 –

+0

지금 일하고있어 –

답변

0
당신은 DOMDocument-> 부하를 사용하여 시도 할 수

($ url). Twitter 피드의 URL은 SSL 없이도 사용할 수 있습니다. SSL로 인해 슬픔이 생기고 보안 버전이 필요없는 경우 시도하십시오.