<?
include("Gracenote.class.php");
include('../config.php');

//You can get these after completing registration at https://developer.gracenote.com
if(!empty($config['gracenote']['userID'])){
	die('You already have an userID specified. No need for another.');
}

$api = new Gracenote\WebAPI\GracenoteWebAPI($config['gracenote']['clientID'], $config['gracenote']['clientTag'], $config['gracenote']['userID']);
$userID = $api->register();

if(!empty($userID)){
	echo "Your userID: ".$userID . '<br>';
	echo "Save this value in the config file and remove this file.";
}
?>
Beispiel #2
0
<?php

include "./php-gracenote/Gracenote.class.php";
// You will need a Gracenote Client ID to use this. Visit https://developer.gracenote.com/
// for more information.
$clientID = "";
// Put your Client ID here.
$clientTag = "";
// Put your Client Tag here.
/* You first need to register your client information in order to get a userID.
Best practice is for an application to call this only once, and then cache the userID in
persistent storage, then only use the userID for subsequent API calls. The class will cache
it for just this session on your behalf, but you should store it yourself. */
$api = new Gracenote\WebAPI\GracenoteWebAPI($clientID, $clientTag);
// If you have a userID, you can specify as third parameter to constructor.
$userID = $api->register();
echo "UserID = " . $userID . "\n";
// Once you have the userID, you can search for tracks, artists or albums easily.
echo "\n\nSearch Tracks:\n";
$results = $api->searchTrack("Kings Of Convenience", "Riot On An Empty Street", "Homesick");
var_dump($results);
echo "\n\nSearch Best Track:\n";
$results = $api->searchTrack("Kings Of Convenience", "Riot On An Empty Street", "Homesick", Gracenote\WebAPI\GracenoteWebAPI::BEST_MATCH_ONLY);
var_dump($results);
echo "\n\nSearch Artist:\n";
$results = $api->searchArtist("Kings Of Convenience");
var_dump($results);
echo "\n\nSearch Album:\n";
$results = $api->searchAlbum("Kings Of Convenience", "Riot On An Empty Street");
var_dump($results);
echo "\n\nFetch Album:\n";