Posted By

bitmanic on 01/04/10


Tagged

search twitter simplexml


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dimispaceman


SimpleXML code for a Twitter search


 / Published in: PHP
 

  1. <?php
  2. // Get the Twitter search results
  3. $xml = simplexml_load_file("http://search.twitter.com/search.atom?q=vespa%20scooter");
  4.  
  5. // Prints the returned array to the page so you can see what's up
  6. // print_r($xml);
  7. ?>
  8.  
  9. <ol id="search-results">
  10.  
  11. <?php
  12. foreach($xml->entry as $e){
  13. $status_link = $e->link[0]['href'];
  14. $user_name = $e->author->name;
  15. $user_link = $e->author->uri;
  16. $thumb = $e->link[1]['href'];
  17. ?>
  18.  
  19. <li class="hentry status search_result">
  20. <span class="thumb vcard author">
  21. <a class="tweet-url profile-pic" href="<?=$user_link?>"><img alt="" src="<?=$thumb?>" width="48" height="48" /></a>
  22. </span>
  23. <span class="status-body">
  24. <a class="tweet-url screen-name" href="<?=$user_link?>"><?=$user_name?></a>
  25. <span id="msgtxt6185685937" class="msgtxt en"><?=$e->content?></span>
  26. </span>
  27. </li>
  28.  
  29. <?php } ?>
  30.  
  31. </ol>

Report this snippet  

You need to login to post a comment.