Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Tenho um código que lê o xml do rss de um perfil no twitter, mas de uma hora pra outra ele começou a apresentar erros que eu não consigo dizer o que pode ser.
Segue o código:
<?php
date_default_timezone_set('America/Sao_Paulo');
$xml = simplexml_load_file("http://search.twitter.com/search.atom?q=+from%3Ashowrural&rpp=5");
// $xml = simplexml_load_file("twitter.xml");
if(count($xml->entry[0])>0){
for($a=0; $a < 2; $a++) {
$date = $xml->entry[$a]->updated;
$content = $xml->entry[$a]->content;
$link = $xml->entry[$a]->link[0]->attributes()->href;
$date = strtotime($date);
$datetime = date('d.m.Y \à\s H:i', $date);
echo "<div class='content'>";
echo "<p>".$content."</p>";
echo "<span><a href='".$link."' title='Link direto do tweet'>em ".$datetime."</a></span>";
echo "</div>";
} //foreach
} else {
echo "<div class='content'>";
echo "<p>Nenhum tweet publicado ainda</p>";
echo "</div>";
}
?>
Os erros:
>
Notice: Trying to get property of non-object in /sites/www/html/showrural/hospedagem/teste_twitter.php on line 8 Notice: Trying to get property of non-object in /sites/www/html/showrural/hospedagem/teste_twitter.php on line 9 Notice: Trying to get property of non-object in /sites/www/html/showrural/hospedagem/teste_twitter.php on line 10 Fatal error: Call to a member function attributes() on a non-object in /sites/www/html/showrural/hospedagem/teste_twitter.php on line 10
Carregando comentários...