Jump to content

Music API not searching any data


nisaar

Recommended Posts

Hi All ....

 

I am new to php and i am droning over here ... We are starting a new online store and I am having a huge problem with my music API. What happens is that the api does a search ...I can vouch for that because I have a mailer that sends me a failed list ...@ this point everything cannot be found. My Dvd's working with the IMDB Api works perfectly and all the info gets stored to my MySql DB.

 

This is my code for the music

 

function GetMusicData($album, $artist, $id)

 

{

global $db;

 

$artist = str_replace(" ", "+", $artist);

$artist = strtolower($artist);

$album = str_replace(" ", "+", $album);

 

$url='http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=801bf08fc2c46659ad7878778edb72b3&artist='.$artist.'&album='.$album.'&autocorrect=1' ;

 

$ch = curl_init ($url);

  curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);

$dt=curl_exec($ch);

curl_close ($ch);

 

                                            $data = new SimpleXmlElement($dt, LIBXML_NOCDATA);

$tracklist = NULL;

$x = (array)$data;

 

Any help would be much appreciated as I can't see why I am not able to get any information. I have just over 9000 entries in my DB of well known and not so well known artists but I can't find any information.                                           

Link to comment
Share on other sites

ok so I changed my API ... now i am getting another error " Error: Client does not accept gzip encoding." Below is my code:

 

Function GetMusicData($price, $album, $artist, $id)

{

global $db;

 

$artist_name = $db->get("select name from music limit 100");

$title = $db->get("select description_short from music limit 100");

$artist = str_replace(" ", "+", $artist);

$artist = strtolower($artist);

$album = str_replace(" ", "+", $album);

 

  $url='http://api.discogs.com/search?type=releases&q=-format:"promo"+format:"album"+format:"CD"+title:"$title"+artist:"$artist_name"~&f=xml' .$artist.'&album='.$album.'&autocorrect=1';

 

$ch = curl_init ($url);

curl_setopt($ch, CURLOPT_HEADER,  'Accept-Encoding: gzip');

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);

curl_setopt($curl, CURLOPT_ENCODING, 'gzip, deflate');

$dt=curl_exec($ch);

curl_close ($ch);

 

              $data = new SimpleXmlElement($dt, LIBXML_NOCDATA);

$tracklist = NULL;

$x = (array)$data;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.