Posted By

screamwork on 06/30/10


Tagged

curl twitter


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

hsousa
dantreacy
convergine
manavecplan


curl - fetch twitter trends


 / Published in: PHP
 

  1. <?php
  2. $url = 'http://search.twitter.com/trends.json';
  3. $ch = curl_init();
  4. curl_setopt($ch, CURLOPT_URL, $url);
  5. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  6. $output = curl_exec($ch);
  7. curl_close($ch);
  8. $data = json_decode($output);
  9. #print_r($data);
  10. echo '<h2>Twitter trending topics ('.$data->as_of.')</h2>';
  11. echo '<ul>';
  12. foreach ($data->trends as $t){
  13. echo '<li><a href="'.$t->url.'">'.$t->name.'</a></li>';
  14. }
  15. echo '</ul>';
  16. ?>

Report this snippet  

You need to login to post a comment.