Return to Snippet

Revision: 28077
at June 30, 2010 10:30 by screamwork


Initial Code
<?php
  $url = 'http://search.twitter.com/trends.json';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $output = curl_exec($ch);
  curl_close($ch);
  $data = json_decode($output);
  #print_r($data);
  echo '<h2>Twitter trending topics ('.$data->as_of.')</h2>';
  echo '<ul>';
  foreach ($data->trends as $t){
    echo '<li><a href="'.$t->url.'">'.$t->name.'</a></li>';
  }
  echo '</ul>';
?>

Initial URL

                                

Initial Description

                                

Initial Title
curl - fetch twitter trends

Initial Tags
curl, twitter

Initial Language
PHP