Warning: file_get_contents(http://www.last.fm/music/Boys Like Girls) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/skylight/public_html/testalbum.php on line 5
Printable View
Warning: file_get_contents(http://www.last.fm/music/Boys Like Girls) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/skylight/public_html/testalbum.php on line 5
Just get the artist out of the Now Playing (try exploding by " - " and then using $variable[0] to get the artist name) and then just put that into the URL you want to query.
i have mine working but it always adds %20's and never works. And with URL Decode it messes up
I have this working with spaces etc.
http://thomas.uk.to/artist.php?artist=The Fratellis
Doesnt make the page an image using GD though.PHP Code:<?php
$artist = $_GET['artist'];
$artist = urldecode($artist);
$url = "http://www.last.fm/music/" . $artist . "/";
$url = eregi_replace(" ", "+", $url);
$data = file_get_contents($url);
$image1start = explode('<div class="imgHolder">', $data);
$image1end = explode('</div>', $image1start[1]);
$image1 = trim($image1end[0]);
$imagestart = explode('<img src="', $image1);
$imageend = explode('" alt', $imagestart[1]);
$image = trim($imageend[0]);
echo '<img src="' . $image . '">';
?>
I have also made one to recieve the artists latest album.
http://thomas.uk.to/album.php?artist=The Fratellis
PHP Code:<?php
$artist = $_GET['artist'];
$artist = urldecode($artist);
$url = "http://www.last.fm/music/" . $artist . "/+albums?order=date";
$url = eregi_replace(" ", "+", $url);
$data = file_get_contents($url);
$image1start = explode('<div class="cover">', $data);
$image1end = explode('</div>', $image1start[1]);
$image1 = trim($image1end[0]);
$imagestart = explode('<img src="', $image1);
$imageend = explode('" alt', $imagestart[1]);
$image = trim($imageend[0]);
echo '<img src="' . $image . '">';
?>
http://imager.ffwbmarion.com/album/Kiss.png
http://imager.ffwbmarion.com/album/B...ke%20girls.png
PHP Code:<?php
header("Content-Type: image/gif");
$artist = $_GET['artist'];
$artist = urldecode($artist);
$url = "http://www.last.fm/music/" . $artist . "/";
$url = eregi_replace(" ", "+", $url);
$data = file_get_contents($url);
$image1start = explode('<div class="imgHolder">', $data);
$image1end = explode('</div>', $image1start[1]);
$image1 = trim($image1end[0]);
$imagestart = explode('<img src="', $image1);
$imageend = explode('" alt', $imagestart[1]);
$image = trim($imageend[0]);
$image2 = imagecreatefromjpeg($image);
imagegif($image2);
?>
There you go :)
Wish last.fm wasnt so slow though
Yea but it gets used alot so it takes a while.
=[
How can I explode: Dawn of the Dude - Set Us Free
into just Dawn of the Dude?
PHP Code:<?php
$song_data = "Dawn of the Dude - Set Us Free";
$song_data_exploded = explode(" - ", $song_data);
?>