Example #1
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
// Call for the album package class with auth data
$apiClass = new lastfmApi();
$artistClass = $apiClass->getPackage($auth, 'artist', $config);
// Setup the variables
$methodVars = array('artist' => 'Green Day');
if ($tags = $artistClass->getTags($methodVars)) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($tags);
    echo '</pre>';
} else {
    die('<b>Error ' . $artistClass->error['code'] . ' - </b><i>' . $artistClass->error['desc'] . '</i>');
}
Example #2
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
// Call for the album package class with auth data
$apiClass = new lastfmApi();
$eventClass = $apiClass->getPackage($auth, 'event', $config);
// Setup the variables
$methodVars = array('event' => '666379', 'status' => 2);
if ($eventClass->attend($methodVars)) {
    echo '<b>Status changed to: ' . $methodVars['status'] . '</b>';
} else {
    die('<b>Error ' . $eventClass->error['code'] . ' - </b><i>' . $eventClass->error['desc'] . '</i>');
}
Example #3
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
$apiClass = new lastfmApi();
$groupClass = $apiClass->getPackage($auth, 'group', $config);
// Setup the variables
$methodVars = array('group' => 'Last.fm Web Services', 'from' => '1217764800', 'to' => '1218369600');
if ($artists = $groupClass->getWeeklyAlbumChart($methodVars)) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($artists);
    echo '</pre>';
} else {
    die('<b>Error ' . $groupClass->error['code'] . ' - </b><i>' . $groupClass->error['desc'] . '</i>');
}
Example #4
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
// Call for the album package class with auth data
$apiClass = new lastfmApi();
$albumClass = $apiClass->getPackage($auth, 'album', $config);
// Setup the variables
$methodVars = array('artist' => 'Green day', 'album' => 'Dookie', 'tags' => array('test', 'testing'));
// Call the method with the variables
if ($albumClass->addTags($methodVars)) {
    // Method returned as a success
    echo '<b>Tags added</b>';
} else {
    // Method returned an error
    die('<b>Error ' . $albumClass->error['code'] . ' - </b><i>' . $albumClass->error['desc'] . '</i>');
}
Example #5
0
<?php

require 'config.php';
require 'class/lastfmapi/lastfmapi.php';
if (isset($_COOKIE['sessionkey']) && isset($_COOKIE['username']) && isset($_COOKIE['subscriber'])) {
    $vars = array('apiKey' => $config['api_key'], 'secret' => $config['secret'], 'username' => $_COOKIE['username'], 'sessionKey' => $_COOKIE['sessionkey'], 'subscriber' => $_COOKIE['subscriber']);
    $lastfmapi_auth = new lastfmApiAuth('setsession', $vars);
    $lastfmapi = new lastfmApi();
    $radioClass = $lastfmapi->getPackage($lastfmapi_auth, 'radio');
    $methodVars = array();
    if ($radio = $radioClass->getPlaylist($methodVars)) {
        echo json_encode($radio);
    } else {
        echo 'error';
    }
}
Example #6
0
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with "Podes musikkmashup".  If not, see <http://www.gnu.org/licenses/>.
Source code available from: 
http://github.com/pode/musikkmashup/
*/
include_once '../config.php';
if (!$config['moduler']['artist']['aktiv']) {
    exit;
}
include_once '../include/functions.php';
include_once '../lastfmapi/lastfmapi.php';
if (!empty($_GET['artist'])) {
    $authVars['apiKey'] = $config['lastfm']['api_key'];
    $auth = new lastfmApiAuth('setsession', $authVars);
    $apiClass = new lastfmApi();
    $artist = $apiClass->getPackage($auth, 'artist');
    $methodVars = array('artist' => avinverter($_GET['artist']));
    if ($art = $artist->getinfo($methodVars)) {
        // Sjekk om det oppstod feil
        if ($artist->error['code']) {
            // Error: show which error and go no further.
            echo '<b>Error ' . $artist->error['code'] . ' - </b><i>' . $artist->error['desc'] . '</i>';
            exit;
        }
        if ($art['name']) {
            echo '<p class="overskrift">' . $art['name'] . '</p>';
            // Bilde
            if ($art['image']['large']) {
                echo '<p class="artistbilde"><img src="' . $art['image']['large'] . '" alt="' . $art['name'] . '" title="' . $art['name'] . '" /></p>';
            }
Example #7
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'venuename' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
$apiClass = new lastfmApi();
$venueClass = $apiClass->getPackage($auth, 'venue', $config);
// Setup the variables
$methodVars = array('venue' => '8805051');
if ($events = $venueClass->getPastEvents($methodVars)) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($events);
    echo '</pre>';
} else {
    die('<b>Error ' . $venueClass->error['code'] . ' - </b><i>' . $venueClass->error['desc'] . '</i>');
}
Example #8
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'tagname' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
$apiClass = new lastfmApi();
$tagClass = $apiClass->getPackage($auth, 'tag', $config);
// Setup the variables
$methodVars = array('tag' => 'RJ');
if ($charts = $tagClass->getWeeklyChartList($methodVars)) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($charts);
    echo '</pre>';
} else {
    die('<b>Error ' . $tagClass->error['code'] . ' - </b><i>' . $tagClass->error['desc'] . '</i>');
}
Example #9
0
<?php

// Include the header
include 'template/header.php';
// Check username was sent
if (!empty($_GET['username'])) {
    // If so: carry no
    // Include the API
    require '../../lastfmapi/lastfmapi.php';
    // Set the API key
    $authVars['apiKey'] = 'fa3af76b9396d0091c9c41ebe3c63716';
    // Pass the apiKey to the auth class to get a none fullAuth auth class
    $auth = new lastfmApiAuth('setsession', $authVars);
    // Call for the tasteometer package class with auth class
    $apiClass = new lastfmApi();
    $userClass = $apiClass->getPackage($auth, 'user');
    // Create a list of tag's that we don't one
    // Mainly ones that don't describe peoples musical taste
    $badTags = array('good', 'seen live', 'favourite', 'favorites', 'favorite artists', 'favourite bands', 'favourites', 'want to see live', 'uk', 'whales', 'my music', 'amazing', 'awesome', 'english', 'fun', 'multiple artists under same name', 'a few of the bands ive seen', 'albums i own', 'music', 'rock gods');
    // Setup the variables get get the users top artists
    $methodVars = array('user' => $_GET['username']);
    // Get the users top artist (with error check)
    if ($artists = $userClass->getTopArtists($methodVars)) {
        // Setup the results array
        $results = array();
        // Lopp through each of the users top artists
        foreach ($artists as $artist) {
            // Create an artists class to use
            $artistClass = $apiClass->getPackage($auth, 'artist');
            // Setup the variables for the artist call
            $methodVars = array('artist' => $artist['name']);
Example #10
0
<?php

// Include the header
include 'template/header.php';
// Check username was sent
if (!empty($_GET['username'])) {
    // If so: carry no
    // Include the API
    require '../../lastfmapi/lastfmapi.php';
    // Set the API key
    $authVars['apiKey'] = 'fa3af76b9396d0091c9c41ebe3c63716';
    // Pass the apiKey to the auth class to get a none fullAuth auth class
    $auth = new lastfmApiAuth('setsession', $authVars);
    // Call for the tasteometer package class with auth class
    $apiClass = new lastfmApi();
    $tasteometerClass = $apiClass->getPackage($auth, 'tasteometer');
    // Creat an array with all the lastfm staff members usernames
    $staffMembers = array('RNR', 'RJ', 'mainstream', 'spencerhyman', 'rregan', 'menardnyc', 'lynn_fischer', 'Orlenay', 'mischa', 'Russ', 'muesli', 'flaneur', 'skr', 'mokele', 'pete_bug', 'sharevari', 'hannahdonovan', 'nova77LF', 'vincro', 'sideb0ard', 'mustaqila', 'joanofarctan', 'fionapinkstars', 'julians', 'lumberjack', 'Jonty', 'martind', 'theneonfever', 'foreverautumn', 'Greg_J', 'grazziee', 'pellitero', 'Korean_Cowboy', 'mxcl', 'Whiskeyface', 'juliasven', 'galeote', 'Edouard', 'jwheare', 'gaoxing', 'gaoxing', 'justanotherider', 'erikfrey', 'E1i45', 'robinlisle', 'fakesensations', 'HawkeVIPER', 'nancyvw', 'underpangs', 'laimee', 'lozzd', 'jonocole', 'por', 'jensnikolaus', 'afonsoduarte', 'dunk', 'massdosage', 'acreature', 'LeJeff', 'lizrice', 'Omnicia', 'rynos', 'miadellocca', 'dmhuk', 'Daniel1986', 'Schrollum', 'michalboo', 'musicmobs', 'xe54', 'liquid986', 'irvinebrown', 'bambidambo', 'nananaina', 'wakehurst2', 'dundez', 'Tars21', 'NisaMishap', 'dukedave', 'klbostee', 'crshamburg');
    // WOW! That's a lot of people
    // Last updated: 03/09/08
    // Setup the results array ready for the results
    $results = array();
    // Loop through each staff member and put the results into the results array
    foreach ($staffMembers as $staffMember) {
        // Setup the variables
        $methodVars = array(1 => array('type' => 'user', 'value' => $_GET['username']), 2 => array('type' => 'user', 'value' => $staffMember));
        if ($result = $tasteometerClass->compare($methodVars)) {
            $key = $result['score'] * 1000000;
            $results[$key] = $result;
        } else {
            die('<b>Error ' . $tasteometerClass->error['code'] . ' - </b><i>' . $tasteometerClass->error['desc'] . '</i>');
Example #11
0
 static function getLovedTracksFor($lastFMUserName)
 {
     $strippedUserName = $lastFMUserName;
     $strippedUserName = preg_replace("/[^a-zA-Z0-9]/", "", $strippedUserName);
     if (strlen($strippedUserName) > 0) {
         $myCache = new Caching("./MashupCache/LovedTracks/", $strippedUserName);
         $tempLastFMAPI = new lastfmApi();
         $tempLastFMAuthority = new lastfmApiAuth('setsession', musicCollection::$lastFMVariables);
         $lastFMUser = $tempLastFMAPI->getPackage($tempLastFMAuthority, 'user', musicCollection::$lastFMConfig);
         // Setup the variables
         $methodVars = array('user' => $lastFMUserName);
         if ($myCache->needToRenewData()) {
             try {
                 // result is an array not a simpleXML Object
                 $result = $lastFMUser->getLovedTracks($methodVars);
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
             $reformatedResult = serialize($result);
             $myCache->saveSerializedDataToFile($reformatedResult);
         } else {
             // It doesn't need to be renewed so use local copy of array
             $result = $myCache->getUnserializedData();
         }
     }
     return $result;
 }
Example #12
0
 function getMusic($music, $id, $band_id)
 {
     $authVars = array('apiKey' => '13846fb92c539b877ff2abc79ede2718', 'secret' => 'ce4450255eb766372b130f0784c15087', 'username' => 'hilkeros', 'sessionKey' => '671bbefd4f15d3ed2fdf524dea62212b', 'subscriber' => 0);
     $auth = new lastfmApiAuth('setsession', $authVars);
     $apiClass = new lastfmApi();
     $artistClass = $apiClass->getPackage($auth, 'artist');
     $trackClass = $apiClass->getPackage($auth, 'track');
     $albumClass = $apiClass->getPackage($auth, 'album');
     if ($music) {
         $methodVars = array('artist' => $music);
         $this->etime = time();
         if ($artist = $artistClass->getInfo($methodVars)) {
             $stat['Lfm']['url'] = $artist['url'];
             $stat['Lfm']['lfm_m_id'] = $id;
             $stat['Lfm']['executetime'] = $this->etime;
             $stat['Lfm']['band_id'] = $band_id;
             $this->Lfm->save($stat);
             $stat = NULL;
             $stat['Lfmlistener']['lfm_m_id'] = $id;
             $stat['Lfmlistener']['listeners'] = $artist['stats']['listeners'];
             $stat['Lfmlistener']['etime'] = $this->etime;
             $this->Lfmlistener->create();
             $this->Lfmlistener->save($stat);
         }
         if ($albums = $artistClass->getTopAlbums($methodVars)) {
             foreach ($albums as $key => $val) {
                 $methodAlbumVars = array('artist' => $music, 'album' => $val['name'], 'mbid' => $val['mbid']);
                 if ($topAlbum = $albumClass->getinfo($methodAlbumVars)) {
                     $alb['Lfmalbum']['rank'] = $val['rank'];
                     $alb['Lfmalbum']['name'] = $val['name'];
                     $alb['Lfmalbum']['playcount'] = $topAlbum['playcount'];
                     $alb['Lfmalbum']['lfm_m_id'] = $id;
                     $alb['Lfmalbum']['etime'] = $this->etime;
                     $this->Lfmalbum->create();
                     $this->Lfmalbum->save($alb);
                 }
                 /*					$qry = "insert into lfm_top_album(stat_id , rank , name , playcount) values ($stat_id,$rank,'$name',$playcount)";
                 						 $result = mysql_query($qry);
                 						 */
                 //      $TopAlbumCount ++ ;
             }
         }
         if ($tracks = $artistClass->getTopTracks($methodVars)) {
             foreach ($tracks as $key => $val) {
                 $methodTrackVars = array('artist' => $music, 'track' => $val['name']);
                 if ($toptrack = $trackClass->getinfo($methodTrackVars)) {
                     $trk['Lfmtrack']['lfm_m_id'] = $id;
                     $trk['Lfmtrack']['rank'] = $val['rank'];
                     $trk['Lfmtrack']['name'] = $val['name'];
                     $trk['Lfmtrack']['playcount'] = $toptrack['playcount'];
                     $trk['Lfmtrack']['etime'] = $this->etime;
                     $this->Lfmtrack->create();
                     $this->Lfmtrack->save($trk);
                 }
                 /*
                 $qry = "insert into lfm_top_tracks(stat_id , rank , name , playcount) values ($stat_id,$rank,'$name',$playcount)";
                 $result = mysql_query($qry);
                 */
             }
             // foreach($tracks as $key => $val)
         }
         return true;
     }
     // if($music)
 }
 function index()
 {
     $program_start_time = microtime(true);
     $this->etime = time();
     $authVars = array('apiKey' => '13846fb92c539b877ff2abc79ede2718', 'secret' => 'ce4450255eb766372b130f0784c15087', 'username' => 'hilkeros', 'sessionKey' => '671bbefd4f15d3ed2fdf524dea62212b', 'subscriber' => 0);
     $auth = new lastfmApiAuth('setsession', $authVars);
     $apiClass = new lastfmApi();
     $artistClass = $apiClass->getPackage($auth, 'artist');
     $trackClass = $apiClass->getPackage($auth, 'track');
     $albumClass = $apiClass->getPackage($auth, 'album');
     $result = $this->Lfm->findAll();
     if ($result) {
         foreach ($result as $key => $lfmdata) {
             $ptime = $lfmdata['Lfm']['executetime'];
             if (date('Ymd', $ptime) != date('Ymd')) {
                 if ($lfmdata['Lfm']['music_group']) {
                     $methodVars = array('artist' => $lfmdata['Lfm']['music_group']);
                     // if($lfmdata['Lfm']['music_group'])
                     if ($artist = $artistClass->getInfo($methodVars)) {
                         // Update lfm_music table
                         $record['Lfm']['lfm_m_id'] = $lfmdata['Lfm']['lfm_m_id'];
                         $record['Lfm']['url'] = $artist['url'];
                         $record['Lfm']['executetime'] = $this->etime;
                         $this->Lfm->save($record);
                         $record = NULL;
                         // Insert latest listeners & time into lfmlisteners table
                         $record['Lfmlistener']['lfm_m_id'] = $lfmdata['Lfm']['lfm_m_id'];
                         $record['Lfmlistener']['listeners'] = $artist['stats']['listeners'];
                         $record['Lfmlistener']['etime'] = $this->etime;
                         $this->Lfmlistener->create();
                         $this->Lfmlistener->save($record);
                         $record = NULL;
                         //} // if($record)
                     }
                     // 	if ( $artist = $artistClass->getInfo($methodVars) )
                     if ($albums = $artistClass->getTopAlbums($methodVars)) {
                         foreach ($albums as $key => $val) {
                             $methodAlbumVars = array('artist' => $lfmdata['Lfm']['music_group'], 'album' => $val['name'], 'mbid' => $val['mbid']);
                             if ($topAlbum = $albumClass->getinfo($methodAlbumVars)) {
                                 // Insert values into lfm_top_album table
                                 $record['Lfmalbum']['lfm_m_id'] = $lfmdata['Lfm']['lfm_m_id'];
                                 $record['Lfmalbum']['rank'] = $val['rank'];
                                 $record['Lfmalbum']['name'] = $val['name'];
                                 $record['Lfmalbum']['playcount'] = $topAlbum['playcount'];
                                 $record['Lfmalbum']['etime'] = $this->etime;
                                 $this->Lfmalbum->create();
                                 $this->Lfmalbum->save($record);
                                 $record = NULL;
                             }
                         }
                         // foreach($albums as $key => $val)
                     }
                     // 			if ( $albums = $artistClass->getTopAlbums($methodVars) ) {
                     if ($tracks = $artistClass->getTopTracks($methodVars)) {
                         foreach ($tracks as $key => $val) {
                             $methodTrackVars = array('artist' => $lfmdata['Lfm']['music_group'], 'track' => $val['name']);
                             if ($toptrack = $trackClass->getinfo($methodTrackVars)) {
                                 // Insert values into lfm_top_tracks
                                 $record['Lfmtrack']['lfm_m_id'] = $lfmdata['Lfm']['lfm_m_id'];
                                 $record['Lfmtrack']['name'] = $val['name'];
                                 $record['Lfmtrack']['rank'] = $val['rank'];
                                 $record['Lfmtrack']['playcount'] = $toptrack['playcount'];
                                 $record['Lfmtrack']['etime'] = $this->etime;
                                 $this->Lfmtrack->create();
                                 $this->Lfmtrack->save($record);
                                 $record = NULL;
                             }
                         }
                         // foreach($tracks as $key => $val)
                     }
                     // if ( $tracks = $artistClass->getTopTracks($methodVars) ) {
                 }
                 // $lfmdata['Lfm']['music_group'
             }
             // if(date('Ymd',$ptime)!=date('Ymd'))
         }
         // foreach($result as $key => $lfmdata)
     }
     // if($result)
     echo "Total execution time : " . (microtime(true) - $program_start_time) . " seconds<br />";
     exit;
 }
Example #14
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
// Call for the album package class with auth data
$apiClass = new lastfmApi();
$geoClass = $apiClass->getPackage($auth, 'geo', $config);
// Setup the variables
$methodVars = array('country' => 'Brazil');
if ($artists = $geoClass->getTopArtists($methodVars)) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($artists);
    echo '</pre>';
} else {
    die('<b>Error ' . $geoClass->error['code'] . ' - </b><i>' . $geoClass->error['desc'] . '</i>');
}
Example #15
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
// Call for the album package class with auth data
$apiClass = new lastfmApi();
$tasteometerClass = $apiClass->getPackage($auth, 'tasteometer', $config);
// Setup the variables
$methodVars = array(1 => array('type' => 'user', 'value' => 'lotrgamemast'), 2 => array('type' => 'artists', 'value' => array('green day', 'athlete', 'feeder', 'mika', 'bloc party')));
if ($results = $tasteometerClass->compare($methodVars)) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($results);
    echo '</pre>';
} else {
    die('<b>Error ' . $tasteometerClass->error['code'] . ' - </b><i>' . $tasteometerClass->error['desc'] . '</i>');
}
Example #16
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
$apiClass = new lastfmApi();
$libraryClass = $apiClass->getPackage($auth, 'library', $config);
// Setup the variables
$methodVars = array('user' => 'lotrgamemast');
if ($artists = $libraryClass->getArtists($methodVars)) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($artists);
    echo '</pre>';
} else {
    die('<b>Error ' . $libraryClass->error['code'] . ' - </b><i>' . $libraryClass->error['desc'] . '</i>');
}
Example #17
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
// Call for the album package class with auth data
$apiClass = new lastfmApi();
$radioClass = $apiClass->getPackage($auth, 'radio', $config);
if ($playlist = $radioClass->getPlaylist()) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($playlist);
    echo '</pre>';
} else {
    die('<b>Error ' . $eventClass->error['code'] . ' - </b><i>' . $eventClass->error['desc'] . '</i>');
}
Example #18
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
$apiClass = new lastfmApi();
$userClass = $apiClass->getPackage($auth, 'user', $config);
// Setup the variables
$methodVars = array('user' => 'RJ');
if ($playlists = $userClass->getPlaylists($methodVars)) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($playlists);
    echo '</pre>';
} else {
    die('<b>Error ' . $userClass->error['code'] . ' - </b><i>' . $userClass->error['desc'] . '</i>');
}
Example #19
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
$apiClass = new lastfmApi();
$playlistClass = $apiClass->getPackage($auth, 'playlist', $config);
// Setup the variables
$methodVars = array('playlistID' => '25168', 'artist' => 'Green Day', 'track' => 'American Idiot');
if ($playlistClass->addTrack($methodVars)) {
    echo '<b>Done!</b>';
} else {
    die('<b>Error ' . $playlistClass->error['code'] . ' - </b><i>' . $playlistClass->error['desc'] . '</i>');
}
Example #20
0
<?php

// Include the API
require '../../lastfmapi/lastfmapi.php';
// Get the session auth data
$file = fopen('../auth.txt', 'r');
// Put the auth data into an array
$authVars = array('apiKey' => trim(fgets($file)), 'secret' => trim(fgets($file)), 'username' => trim(fgets($file)), 'sessionKey' => trim(fgets($file)), 'subscriber' => trim(fgets($file)));
$config = array('enabled' => true, 'path' => '../../lastfmapi/', 'cache_length' => 1800);
// Pass the array to the auth class to eturn a valid auth
$auth = new lastfmApiAuth('setsession', $authVars);
$apiClass = new lastfmApi();
$trackClass = $apiClass->getPackage($auth, 'track', $config);
// Setup the variables
$methodVars = array('artist' => 'Green Day', 'track' => 'American Idiot');
if ($tracks = $trackClass->getInfo($methodVars)) {
    echo '<b>Data Returned</b>';
    echo '<pre>';
    print_r($tracks);
    echo '</pre>';
} else {
    die('<b>Error ' . $trackClass->error['code'] . ' - </b><i>' . $trackClass->error['desc'] . '</i>');
}
Example #21
0
 public function getInfo(SSLTrack $track)
 {
     $vars = array();
     $vars['apiKey'] = $this->config['api_key'];
     $vars['secret'] = $this->config['api_secret'];
     $auth = new lastfmApiAuth('setsession', $vars);
     $lfm = new lastfmApi();
     /* @var $trackP lastfmApiTrack */
     /* @var $artistP lastfmApiArtist */
     $trackP = $lfm->getPackage($auth, 'track');
     $artistP = $lfm->getPackage($auth, 'artist');
     //$track_info = $trackP->getInfo(array('artist' => $track->getArtist(), 'title' => $track->getTitle()));
     $artist_info = $artistP->getInfo(array('artist' => $track->getArtist()));
     $artist_images = $artistP->getImages(array('artist' => $track->getArtist()));
     $all = array('artist' => $artist_info, 'images' => $artist_images);
     return $all;
 }