使用LastFM API打印专辑;在非对象错误上调用成员函数 search()


Using LastFM API to print out albums; call to a member function search() on a non-object error

我正在尝试实现LastFM API以使用此处看到的软件包打印出一些专辑:https://github.com/matto1990/PHP-Last.fm-API

我在控制器中具有以下功能:

public function album_print() {
        // Put the auth data into an array
        $authVars = array(
                'apiKey' => '*******************************',
                'secret' => '*******************************',
        );
        $config = array(
            'enabled' => true,
            'path' => '/Applications/MAMP/htdocs/**********/*****************/app/lastfmapi/',
            'cache_length' => 1800
        );
        // Pass the array to the auth class to return a valid auth
        $auth = new lastfmApiAuth('getsession', $authVars);
        // Call for the album package class with auth data
        $apiClass = new lastfmApi();
        $albumClass = $apiClass->getPackage($auth, 'album', $config);
        // Setup the variables
        $methodVars = array(
        'album' => 'In Rainbows',
        'page' => 1,
        'limit' => 10
        );
        if ( $results = $albumClass->search($methodVars) ) {
        echo '<b>Data Returned</b>';
        echo '<pre>';
        print_r($results);
        echo '</pre>';
        }
        else {
        die('<b>Error '.$albumClass->error['code'].' - </b><i>'.$albumClass->error['desc'].'</i>');
        }
    }

我正在尝试使用album.search功能从给定的输入中查找专辑。 但是,当我运行它时,我收到以下错误:

Call to a member function search() on a non-object

知道为什么会这样吗? 我遵循了这里的例子:https://github.com/matto1990/PHP-Last.fm-API/blob/master/examples/album.search/index.php

或多或少。 谢谢你的帮助。 (这是在 Laravel 4 中的控制器中)

这需要一个访问令牌。 这就是无法正确读取对象的原因。