Ver Mensaje Individual
  #4 (permalink)  
Antiguo 30/04/2013, 21:29
Avatar de andresdzphp
andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: Error en código PHP del tipo T_OBJECT_OPERATOR

A mi me funciona perfectamente, que más errores te da?

Prueba con SimpleXML

Código PHP:
Ver original
  1. <?php
  2.  
  3. $sxe = new SimpleXMLElement('https://api.twitter.com/1/statuses/user_timeline.rss?user_id=201519348&count=20', null, true);
  4.  
  5. $feed = array();
  6.  
  7. foreach ($sxe->channel->item as $node) {
  8.     $feed[] = array (
  9.     'title' => $node->title,
  10.     'link' => $node->link,
  11.     'date' => $node->pubDate
  12.     );
  13. }

y con DOM esto me funciona:

Código PHP:
Ver original
  1. $rss = new DOMDocument();
  2.  
  3. $rss->load('https://api.twitter.com/1/statuses/user_timeline.rss?user_id=201519348&count=20');
  4.  
  5. $feed = array();
  6.  
  7. foreach ($rss->getElementsByTagName('item') as $node) {
  8.   $feed[] = array (  
  9.     'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
  10.     'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
  11.     'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
  12.     );
  13. }
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP