Пример #1
0
 public function getAlbumArt($spotifyString)
 {
     return parent::__construct($this->embed_url . $spotifyString);
 }
include_once "Allerhande.php";
include_once "countrycolors.php";
include_once "huemanager.php";
include_once "bolmanager.php";
include_once "spotify.php";
include_once "schiphol.php";
//Getting those annoying notices and warnings out of the way
error_reporting(0);
// ini_set('display_errors', 1);
$flightId = $_REQUEST['flightId'];
$numberOfRecipes = $_REQUEST['numberOfRecipes'];
$airportCode = Transavia::getCountryCodeForJourney($flightId);
$countryCode = CountryCode::getCountryCodeForIATA($airportCode);
$fileName = "cache/cache.json." . $flightId . $numberOfRecipes;
$jsonObject = new StdClass();
if (file_exists($fileName)) {
    $jsonObject = json_decode(file_get_contents($fileName));
} else {
    $jsonObject->recepten = Recepten::getReceptenForCountry($countryCode, $numberOfRecipes);
    $jsonObject->colors->RGB = CountryColors::getMainColors($countryCode);
    $jsonObject->colors->HUE = CountryColors::array_RGB_TO_HUE($jsonObject->colors->RGB);
    $jsonObject->producten = BolManager::getProductsForCountry($search = Countries::getDutchName($countryCode));
    //$jsonObject->bagbeltNumber = Schiphol::getBagbeltNumber($journeyCode);
    $jsonObject->spotify = Spotify::getTrack($countryCode);
    foreach ($jsonObject->recepten as &$r) {
        $r->receptimagehd = Allerhande::getHighResImage($r->recepturl);
    }
    file_put_contents($fileName, json_encode($jsonObject));
}
//HueManager::setColors($jsonObject->colors->HUE);
echo json_encode($jsonObject);
<?php

require 'class.php';
$csrf = "";
// Spotify csrf
$Spotify = new Spotify($csrf);
$playlist = "";
// Default Playlist
if (isset($_GET['play'])) {
    if (empty($_GET['play'])) {
        $Spotify->play($playlist);
    } else {
        $Spotify->play($_GET['play']);
    }
} elseif (isset($_GET['skip'])) {
    $Spotify->skip($playlist);
} elseif (isset($_GET['pause'])) {
    $Spotify->pause();
} elseif (isset($_GET['unpause'])) {
    $Spotify->unpause();
}
<?php

require 'spotify.class.php';
$Spotify = new Spotify(file_get_contents('php://input'));
if (isset($Spotify->data->request)) {
    if ('IntentRequest' != $Spotify->type) {
        $Spotify->error();
    }
    if ($Spotify->name == "Play") {
        $Spotify->spotify("play");
        $Spotify->sendResponse("Spotify is now playing!");
        exit;
    } elseif ($Spotify->name == "Pause") {
        $Spotify->spotify("pause");
        $Spotify->sendResponse("Song paused!");
        exit;
    } elseif ($Spotify->name == "Unpause") {
        $Spotify->spotify("unpause");
        $Spotify->sendResponse("Song resumed!");
        exit;
    } elseif ($Spotify->name == "Skip") {
        $Spotify->spotify("skip");
        $Spotify->sendResponse("Song skipped!");
        exit;
    } elseif ($Spotify->name == "SearchSong") {
        $Spotify->spotifySearch($Spotify->value->SongName->value);
        exit;
    } else {
        $Spotify->sendResponse('Spotify didn\'t like that question!');
        exit;
    }
Пример #5
0
<?php

require_once 'spotify.class.php';
// Search for an artist by its name
$artist = Spotify::searchArtist('Maroon 5');
// Take a look at the response
echo '<pre>';
print_r($artist);
echo '<pre>';
echo "test";
Пример #6
0
<?php

$s = new Spotify("spotify_appkey.key", "user", "pass");

//$f = $s->getStarredPlaylist();
//var_dump($f->getTracks());

$playlists = $s->getPlaylists();

$pl = $playlists[7];

printf("\n\tPlaylist name: %s\n", $pl);
printf("\tOwner: %s\n", $pl->getOwner());
printf("\tCollaborative: %s\n", $pl->isCollaborative() ? 'yes' : 'no');

//if (!$playlists[7]->rename("hove 2010")) {
//	printf("rename failed\n");
//}

echo "\n";

$tracks = $playlists[7]->getTracks();
foreach ($tracks as $track) {
	$duration = $track->getDuration();
	$album = $track->getAlbum();

	printf("%s - %s (album: %s, year: %d, #%d) [%02d:%02d] %s [%d%%]\n",
			$track->getArtist(),
			$track,
			$album,
			$album->getYear(),
Пример #7
0
<?php

require 'main.php';
$username = $_GET['u'];
$page = $_GET['p'];
$data = array();
$last_fm = new LastFM('72fe81934c0a8b1e45950df864a9a442');
$spotify = new Spotify($mysql_host, $mysql_username, $mysql_password, $mysql_database);
$data['artists'] = $last_fm->get_artists($username, $page);
$total_pages = $last_fm->get_total_pages();
$data['spotify_uris'] = $spotify->look_up_artists($data['artists']);
if ($page > 1) {
    $data['last_page'] = $page - 1;
}
if ($page < $total_pages) {
    $data['next_page'] = $page + 1;
}
echo $m->render('run', $data);