Page 1 of 1

Find spotify information

Posted: Mon Nov 02, 2009 4:11 am
by JKM
I want to find spotify information from a Spotify link, and I found a site where I can find it.

Code: Select all

<?php
    if(strlen($_GET['uri']) == 22) {
        $url = file_get_contents("http://spotify.url.fi/track/".$_GET['uri']);
        preg_match('/<title>(.*)<\/title>/i',$url,$output);
        $explode = explode("&mdash;", $output[1]);
        print_r($explode);
?>
    [Spotify Info:] <?php echo $artist; ?> - <?php echo $song; ?> [<?php echo $album; ?>]
<?  
    } else {
        echo 'Error - wrong link format.';
    }
?>
Warning: file_get_contents(http://spotify.url.fi/track/4OSRg1faLprPCt86C80zWt) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /public_html/spotInfo.php on line 3
How do I solve this, and if it's not possible, does anyone know a way to find spotify information?

Re: Find spotify information

Posted: Mon Nov 02, 2009 4:45 am
by cpetercarter
My guess is that allow_url_fopen is set to 'off' in your php.ini file. This is a security measure intended to prevent remote file execution hacks, so even if you can change this setting it would probably be better not to.

The alternative is to use cURL to access the remote URL. Google 'cURL' - you'll find lots of examples.

Re: Find spotify information

Posted: Mon Nov 02, 2009 5:11 am
by JKM
Nevermind, I found a way. Thanks for your help!