我正在尝试实现 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 的控制器中)