Skip to content

Instantly share code, notes, and snippets.

@codyjames
Created November 8, 2011 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codyjames/1349101 to your computer and use it in GitHub Desktop.
Save codyjames/1349101 to your computer and use it in GitHub Desktop.
Last.fm PHP cURL JSON
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist=Josh+Harmony&api_key=d3fcabf421291d107802fce0fe2c2825&format=json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
$content = curl_exec($ch);
curl_close($ch);
$content = json_decode($content);
$events = $content->events;
print_r($content);
foreach ($events as $event) {
$date = $event->startDate;
if ($date) {
$month = substr($date, 8, 3);
$day = substr($date, 5, 2);
echo '<tr><td class="evDate">'.$month.' '.$day.'</td><td class="evState">'.$event->venue->location->city.'</td><td class="evLoc"><a href="http://maps.google.com/maps?q='.$event->venue->geo:point->geo:lat.',-'.$event->venue->geo:point->geo:lat.'">'.$event->venue->name.'</a></td></tr>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment