I'm trying to regularly retrieve JSON album data from the Last.FM API, and since they don't support JSONP I'm using a PHP Proxy to circumvent the cross-domain limitation. Here's my PHP proxy:
<?php
$artist = $_GET["artist"];
$album = $_GET["album"];
$content = file_get_contents('http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=APIKEY=' . $artist . '&album=' . $album . '&format=json');
echo $content;
?>
As you can see I'm using GET to specify the artist and album, so the URL would look like albumartproxy.php?artist=Jake%20Bugg&album=Jake%20Bugg
But for some reason I get the following error when I try to run the proxy:
Warning: file_get_contents(http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=037358e302c80571663e6a7a66b1dc05&artist=Jake Bugg&album=Jake Bugg&format=json) [function.file-get-contents]: failed to open stream: HTTP request failed! in /MYDOMAIN/albumartproxy.php on line 6
When I access the API URL directly it works? Can someone help? What am I doing wrong?