Login   Register  
PHP Classes
elePHPant
Icontem

File: details.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Mikael  >  MetaTune  >  details.php  >  Download  
File: details.php
Role: Example script
Content type: text/plain
Description: Detail lookup example
Class: MetaTune
Retrieve music information using Spotify API
Author: By
Last change:
Date: 2010-05-13 03:25
Size: 3,245 bytes
 

Contents

Class file image Download
<?php
require_once("lib/config.php");
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="no-NB">
    <head profile="http://gmpg.org/xfn/11">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="keywords" content="Spotify Metadata API, Mikael Brevik, PHP Lib, Spotify" />
        <meta name="description" content="Test av MBSpotifyLib." />
        <title>MetaTune - Demo Details</title>
        <link type="text/css" rel="stylesheet" href="./demo.css" />
    </head>
    <body>
        <div id="wrapper">
            <?php
            
if (DEBUG) {
                
$start microtime();
            }

            
$spotify MetaTune::getInstance();
            try {
                
$content $spotify->lookup($_GET['id']);
            } catch (
MetaTuneException $ex) {
                die(
"<pre>Error\n" $ex "</pre>");
            }
            
$artist $content->getArtist();
            
?>
                        <ul>
                            <li><strong>Track:</strong> <a href="<?php echo $content->getURL() ?>"><?php echo $content->getTitle(); ?></a></li>
                            <li><strong>Artist:</strong> <a href="<?php echo (is_array($artist)) ? $artist[0]->getURL() : $artist->getURL(); ?>"><?php echo $content->getArtistAsString() ?></a></li>
                            <li><strong>Album:</strong> <a href="<?php echo $content->getAlbum()->getURL() ?>"><?php echo $content->getAlbum(); ?></a></li>
                            <li><strong>Duration:</strong> <?php echo $content->getLengthInMinutesAsString(); ?></li>
                            <li><strong>Popularity:</strong> <?php echo $content->getPopularityAsPercent(); ?>%</li>
                            <li><strong>Track Spotify URI:</strong> <?php echo $content->getURI(); ?></li>
                            <li><strong>Artist Spotify URI:</strong> <?php echo (is_array($artist)) ? $artist[0]->getURI() : $content->getArtist()->getURI(); ?></li>
                            <li><strong>Album Spotify URI:</strong> <?php echo $content->getAlbum()->getURI(); ?></li>
                        </ul>
            <hr />
            <?php
            
try {
                
$album $spotify->lookup($content->getAlbum()->getURI());
                echo 
"<h3>Details, Album:</h3><pre>" print_r($album1) . "</pre>";

                if (
is_array($artist)) {
                    
$artist $spotify->lookup($artist[0]->getURI());
                    echo 
"<h3>Details, artist:</h3><pre>" print_r($artist1) . "</pre>";
                } else {
                    
$artist $spotify->lookup($content->getArtist()->getURI());
                    echo 
"<h3>Details, artist:</h3><pre>" print_r($artist1) . "</pre>";
                }
            } catch (
MetaTuneException $ex) {
                die(
"<pre>Error \n" $ex->getCode() . "\n" $ex->getMessage() . "</pre>");
            }


            if (
DEBUG) {
                
$end microtime();
                echo 
"<pre>Debug time: " . ($end $start) . "</pre>";
            }
            
?>
        </div>
    </body>
</html>