Created
November 3, 2012 15:27
-
-
Save nizz/4007655 to your computer and use it in GitHub Desktop.
Last.fm bio (blog.utopianlabs.com/2011/12/adding-a-last-fm-bio-to-your-website/)
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
body{ | |
width: 600px; | |
margin: 20px auto; | |
color: #444444; | |
font-family: sans-serif; | |
font-size: 14px; | |
} | |
a { | |
text-decoration: none; | |
color: #000000; | |
} | |
a:hover{ | |
color: #FF0000; | |
} | |
.data img { | |
float: left; | |
margin: 0 15px 15px 0; | |
} | |
.data h1{ | |
color: #FF4444; | |
text-transform: lowercase; | |
} | |
.data p{ | |
text-align: justify; | |
} | |
.data h3{ | |
font-size: 12px; | |
} | |
.list { | |
padding: 0; | |
margin: 0; | |
font-size: 12px; | |
} | |
.list li{ | |
display: inline; | |
padding-left: 3px; | |
} | |
.list li:after{ | |
content: ','; | |
} | |
.list li:last-child:after{ | |
content: ''; | |
} |
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
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<link href="public/css/site.css" type="text/css" rel="stylesheet"> | |
<head> | |
<body> | |
<?php | |
$ch = curl_init(); | |
$artist = strtolower($_GET["artist"]); | |
$fields = array('method' => 'artist.getInfo', | |
'artist' => $artist, | |
'api_key' => 'your_api_key'); | |
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } | |
rtrim($fields_string,'&'); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 10); | |
curl_setopt($ch, CURLOPT_URL, 'http://ws.audioscrobbler.com/2.0/'); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); | |
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
$s = simplexml_load_string($response); | |
?> | |
<div> | |
<h1><?php print $artist; ?></h1> | |
<img src="<?php print $s->artist->image[3]; ?>" alt="<?php print $artist; ?>" /> | |
<p><?php print nl2br(strip_tags($s->artist->bio->content)); ?></p> | |
<h3>Tags:</h3> | |
<ul> | |
<?php | |
foreach($s->artist->tags->tag AS $tag) | |
{?> | |
<li><a href ="#"><?php print $tag->name;?></li></a> | |
<?php | |
} | |
?> | |
</ul> | |
<h3>Similar Artists:</h3> | |
<ul> | |
<?php | |
foreach($s->artist->similar->artist AS $similar) | |
{?> | |
<li><a href ="#"><?php print $similar->name; ?></li></a> | |
<?php | |
} | |
?> | |
</ul> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment