1

我正在尝试使用从https://github.com/matto1990/PHP-Last.fm-API下载的包通过 php 连接到 Last.fm api 。这是我的代码:

      public function getTopArtists($methodVars) {
    // Check for required variables
    if ( !empty($methodVars['user']) ) {
        $vars = array(
            'method' => 'user.gettopartists',
            'api_key' => $this->auth->apiKey
        );
        $vars = array_merge($vars, $methodVars);

        if ( $call = $this->apiGetCall($vars) ) {
            if ( count($call->topartists->artist) > 0 ) {
                $i = 0;
                foreach ( $call->topartists->artist as $artist ) {
                    $topartists[$i]['name'] = (string) $artist->name;
                    $topartists[$i]['rank'] = (string) $artist['rank'];
                    $topartists[$i]['playcount'] = (string) $artist->playcount;
                    $topartists[$i]['mbid'] = (string) $artist->mbid;
                    $topartists[$i]['url'] = (string) $artist->url;
                    $topartists[$i]['streamable'] = (string) $artist->streamable;
                    $topartists[$i]['images']['small'] = (string) $artist->image[0];
                    $topartists[$i]['images']['medium'] = (string) $artist->image[1];
                    $topartists[$i]['images']['large'] = (string) $artist->image[2];
                    $i++;
                }

                return $topartists;
            }
            else {
                $this->handleError(90, 'This user has no top artists');
                return FALSE;
            }
        }
        else {
            return FALSE;
        }
    }
    else {
        // Give a 91 error if incorrect variables are used
        $this->handleError(91, 'You must include artist variable in the call for this method');
        return FALSE;
    }
}

但是当我尝试执行相同的操作时,我收到一条消息:错误 99 - 无法建立连接,因为目标机器主动拒绝了它。

4

0 回答 0