You are here

Show Twitters

Status message

Error:DOMDocument::load(http://twitter.com/statuses/public_timeline.xml): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found (/export/data/www/instructors7/sites/instructors.dwrl.utexas.edu.wiedner/modules/querypath/QueryPath/QueryPath.php: 2002)

Fetch and display the public twitter feed.

Display the most recent entries on the Twitter public timeline.

The Code:


      <?php
      $ul 
qp('<?xml version='1.0'?><ul/>');
      
$url 'http://twitter.com/statuses/public_timeline.xml';
      
$tpl '<li>
        <div style='
height55px'>
        <img style='
float:left' src='@img'/>
        <strong>@uname </strong><em>@ts</em><br/>
        @txt
        </div>
      </li>'
;
      foreach (
qp($url'status') as $status) {
        
$data = array();
        
$data['@ts'] = substr($status->children('created_at')->text(), 020);
        
$data['@txt'] = $status->next('text')->text();
        
$data['@uname'] = htmlentities($status->parent()->find('user>screen_name')->text());
        
$data['@img'] = $status->next('profile_image_url')->text();
        
$data strtr($tpl$data);
        
$ul->append($data);
      }
      
$out .= $ul->html();
      
?>

References:

The QueryPath API