Question

I am using Last.FM api and using this package http://www.last.fm/api/show/album.getInfo

I searched SO and other in google, nobody seems to be having this issue...strangely...

As per documentation, I should get a list of tracks. Nope. Nada. I do get data back, so my API calls are working. My app is not blacklisted, I can get everything else from last.fm, but the tracks are missing...everything else is as described. - here is a var_dump() of my call:

array(10) {
  ["name"]=>
  string(15) "All Hallow's EP"
  ["artist"]=>
  string(3) "AFI"
  ["lastfmid"]=>
  string(7) "2027169"
  ["mbid"]=>
  string(0) ""
  ["url"]=>
  string(46) "http://www.last.fm/music/AFI/All+Hallow%27s+EP"
  ["releasedate"]=>
  bool(false)
  ["image"]=>
  array(3) {
    ["small"]=>
    string(50) "http://userserve-ak.last.fm/serve/34s/35949507.png"
    ["medium"]=>
    string(50) "http://userserve-ak.last.fm/serve/64s/35949507.png"
    ["large"]=>
    string(51) "http://userserve-ak.last.fm/serve/174s/35949507.png"
  }
  ["listeners"]=>
  string(5) "47506"
  ["playcount"]=>
  string(6) "316093"
  ["toptags"]=>
  array(5) {
    [0]=>
    array(2) {
      ["name"]=>
      string(4) "punk"
      ["url"]=>
      string(27) "http://www.last.fm/tag/punk"
    }
    [1]=>
    array(2) {
      ["name"]=>
      string(12) "albums i own"
      ["url"]=>
      string(39) "http://www.last.fm/tag/albums%20i%20own"
    }
    [2]=>
    array(2) {
      ["name"]=>
      string(9) "punk rock"
      ["url"]=>
      string(34) "http://www.last.fm/tag/punk%20rock"
    }
    [3]=>
    array(2) {
      ["name"]=>
      string(13) "hardcore punk"
      ["url"]=>
      string(38) "http://www.last.fm/tag/hardcore%20punk"
    }
    [4]=>
    array(2) {
      ["name"]=>
      string(3) "afi"
      ["url"]=>
      string(26) "http://www.last.fm/tag/afi"
    }
  }
}

Yes, I tried this with different albums, where I know last fm has tracks.... (this album: http://www.last.fm/music/AFI/All+Hallow%27s+EP) ...even one stremable track.

So did Last.FM change their getInfo() result for album and did not update the documentation? Am I missing something? I am passing all required params to the call.

Basically, I guess my question is: anyone else has the same issue or just me?

Était-ce utile?

La solution

My fix looked like this:

        if ( ! empty($call->album->tracks))
        {
            for( $n = 0 ; $n < count($call->album->tracks->track); $n++)
            {
                // This is identical to how tags is done...
                $info['tracks'][$n]['name'] = (string) $call->album->tracks->track[$n]->name;
                $info['tracks'][$n]['url'] = (string) $call->album->tracks->track[$n]->url;
            }
        }

Autres conseils

YOO Guys, I figured it out. That API you're using is not complete.

Go look at album.php and function getInfo($methodVars); you will see that tracks are not assigned to return variable.

I added the following somewhere around line 134:

        $i = 0;
        foreach ( $call->album->tracks->track as $track ) {
            $info['tracks'][$i]['name'] = (string) $track->name;
            $info['tracks'][$i]['rank'] =(string)$track['rank'][0];
            $info['tracks'][$i]['duration'] = (string) $track->duration;
            $i++;
        }

Hope this helps.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top