Created
November 8, 2011 20:34
-
-
Save codyjames/1349101 to your computer and use it in GitHub Desktop.
Last.fm PHP cURL JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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