<?

/************************************************************************
*
*                  OMS Web Service Functions 1.4
*                  -----------------------------
*
*     Copyright:   (C) 2007 moving primates GmbH
*      Function:   GetArtistSongs
*   Description:   Gets the data of all uploaded songs of one artist.
*   Change Date:   12/Jun/2007
*
*************************************************************************
*
*   REQUIRED ELEMENTS:
*
*   The following required elements must be send with the request:
*
*   - ArtistID
*   - Fieldlist
*
*   FIELD ELEMENTS:
*
*   The following are Field elements which define what you get back from
*   the Web Service function. They must be named "Field", their value
*   must be the exact name of the following enumeration and they must be
*   created as a child element of "Fieldlist".
*
*   Field elements are optional, however it is required that you
*   create at least one; their send order is irrelevant.
*
*   - SongTitle
*   - Composer
*   - LyricsAuthor
*   - Distribution
*   - PerformingRightsOrganization
*   - PerformingRightsOrganizationID
*   - OtherPerformingRightsOrganization
*   - SongPrice
*   - Year
*   - SongLabel
*   - SongPictureExists
*   - SongLyrics
*   - LoFiExists
*   - HiFiExists
*   - DownloadExists
*   - FileSize
*   - UploadDate
*   - SongGenreID
*   - SongGenreParentID
*   - SongGenreTopParentID
*   - SongGenreName
*   - SongParentGenreName
*   - SongTopParentGenreName
*   - PlayChartGenrePos
*   - PlayChartParentGenrePos
*   - PlayChartTopParentGenrePos
*   - PlayChartAllGenresPos
*   - DownloadChartGenrePos
*   - DownloadChartParentGenrePos
*   - DownloadChartTopParentGenrePos
*   - DownloadChartAllGenresPos
*
*************************************************************************
*   More info about elements and the functions can be found inside
*   the documentation.
************************************************************************/

$ArtistID = "42028"; // Example ID from an artist
include("inc/config.php"); // Example path, point it to your config.php


$dom = create_document();
$root = create_root_element($dom, "OMS");
create_element_attribute($root, "xmlns", $oms_cfg['artist_data_xmlns'] . "/GetArtistSongs");


// Here we are defining the REQUIRED elements

$el_mp3_id = create_element($dom, "ArtistID");
set_element_value($dom, $el_mp3_id, $ArtistID);


// Here we are defining the FIELDLIST and its elements (requesting all available)

$el_fields_list = create_element($dom, "FieldList");

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "Mp3ID");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongTitle");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "Composer");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "LyricsAuthor");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "Distribution");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "PerformingRightsOrganization");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "PerformingRightsOrganizationID");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "OtherPerformingRightsOrganization");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongPrice");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "Year");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongLabel");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongPictureExists");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongLyrics");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "LoFiExists");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "HiFiExists");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "DownloadExists");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "FileSize");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "UploadDate");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongGenreID");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongGenreParentID");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongGenreTopParentID");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongGenreName");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongParentGenreName");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "SongTopParentGenreName");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "PlayChartGenrePos");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "PlayChartParentGenrePos");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "PlayChartTopParentGenrePos");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "PlayChartAllGenresPos");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "DownloadChartGenrePos");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "DownloadChartParentGenrePos");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "DownloadChartTopParentGenrePos");
add_child_element($el_fields_list, $el_field);

$el_field = create_element($dom, "Field");
set_element_value($dom, $el_field, "DownloadChartAllGenresPos");
add_child_element($el_fields_list, $el_field);


// Preparing the XML which is going to be send

add_child_element($root, $el_mp3_id);
add_child_element($root, $el_fields_list);

$xml_str = dump_to_string($dom);

$par = array("String_1" => $oms_cfg['ws_login'],
            
"String_2" => $oms_cfg['ws_password'],
            
"String_3" => $xml_str );
            

// Executing the Web Service function "GetArtistSongs"

$GetArtistSongs = ProcessWSCall($oms_cfg['artist_data_ws_url'], "GetArtistSongs", $par, $oms_cfg['artist_data_xmlns']);


// Counting available songs

if(isset($GetArtistSongs['ArtistID']))
{
    if(isset(
$GetArtistSongs['SongList'][0]['Song']))
    {
        
$song_count = sizeof($GetArtistSongs['SongList'][0]['Song']);
    }
    else
    {
        
$song_count = 0;
    }
}


/************************************************************************
*
*   From here on we assign the content of the array to variables and
*   create some example output. This was done so you can see something
*   when opening the PHP files with your browser.
*
*   If you are looking for this code without any comments or output,
*   then check out the folder 'minimal_code'.
*
************************************************************************/

?>
<style type="text/css">
<!--
.font {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
}
-->
</style>
<span class="font"> <strong>We sent the following elements with our <u>REQUEST</u>:</strong><br />
<ul>
    <li><em>ArtistID</em> - value was &quot;42028&quot;, an example ID from an artist</li>
    <li><em>Fieldlist</em> - the requested child elements were: <i>
        <ul>
            <li>Mp3ID</li>
            <li>SongTitle</li>
            <li>Composer</li>
            <li>LyricsAuthor</li>
            <li>Distribution</li>
            <li>PerformingRightsOrganization</li>
            <li>PerformingRightsOrganizationID</li>
            <li>OtherPerformingRightsOrganization</li>
            <li>SongPrice</li>
            <li>Year</li>
            <li>SongLabel</li>
            <li>SongPictureExists</li>
            <li>SongLyrics</li>
            <li>LoFiExists</li>
            <li>HiFiExists</li>
            <li>DownloadExists</li>
            <li>FileSize</li>
            <li>UploadDate</li>
            <li>SongGenreID</li>
            <li>SongGenreParentID</li>
            <li>SongGenreTopParentID</li>
            <li>SongGenreName</li>
            <li>SongParentGenreName</li>
            <li>SongTopParentGenreName</li>
            <li>PlayChartGenrePos</li>
            <li>PlayChartParentGenrePos</li>
            <li>PlayChartTopParentGenrePos</li>
            <li>PlayChartAllGenresPos</li>
            <li>DownloadChartGenrePos</li>
            <li>DownloadChartParentGenrePos</li>
            <li>DownloadChartTopParentGenrePos</li>
            <li>DownloadChartAllGenresPos</li>
        </ul>
        </i> </li>
</ul>
<br />
<strong>We got back the following array in <u>RESPONSE</u>:</strong><br />
<pre><? var_dump($GetArtistSongs); ?>
</pre>
<br />
<strong>We assign the array to  seperate variables and <u>OUTPUT</u> these (without any design here):</strong><br />
<ul>
    <li>Artist ID: <? echo $ArtistID; ?></li>
    <?
for($i=0;$i<$song_count;$i++)
{
    
$ArtistID = $GetArtistSongs['ArtistID'][0];
    
$Mp3ID = $GetArtistSongs['SongList'][0]['Song'][$i]['Mp3ID'];
    
$SongTitle = $GetArtistSongs['SongList'][0]['Song'][$i]['SongTitle'];
    
$Composer = $GetArtistSongs['SongList'][0]['Song'][$i]['Composer'];
    
$LyricsAuthor = $GetArtistSongs['SongList'][0]['Song'][$i]['LyricsAuthor'];
    
$Distribution = $GetArtistSongs['SongList'][0]['Song'][$i]['Distribution'];
    
$PerformingRightsOrganization = $GetArtistSongs['SongList'][0]['Song'][$i]['PerformingRightsOrganization'];
    
$PerformingRightsOrganizationID = $GetArtistSongs['SongList'][0]['Song'][$i]['PerformingRightsOrganizationID'];
    
$OtherPerformingRightsOrganization = $GetArtistSongs['SongList'][0]['Song'][$i]['OtherPerformingRightsOrganization'];
    
$SongPrice = $GetArtistSongs['SongList'][0]['Song'][$i]['SongPrice'];
    
$Year = $GetArtistSongs['SongList'][0]['Song'][$i]['Year'];
    
$SongLabel = $GetArtistSongs['SongList'][0]['Song'][$i]['SongLabel'];
    
$SongPictureExists = $GetArtistSongs['SongList'][0]['Song'][$i]['SongPictureExists'];
    
$SongLyrics = $GetArtistSongs['SongList'][0]['Song'][$i]['SongLyrics'];
    
$LoFiExists = $GetArtistSongs['SongList'][0]['Song'][$i]['LoFiExists'];
    
$HiFiExists = $GetArtistSongs['SongList'][0]['Song'][$i]['HiFiExists'];
    
$DownloadExists = $GetArtistSongs['SongList'][0]['Song'][$i]['DownloadExists'];
    
$FileSize = $GetArtistSongs['SongList'][0]['Song'][$i]['FileSize'];
    
$UploadDate = $GetArtistSongs['SongList'][0]['Song'][$i]['UploadDate'];
    
$SongGenreID = $GetArtistSongs['SongList'][0]['Song'][$i]['SongGenreID'];
    
$SongGenreParentID = $GetArtistSongs['SongList'][0]['Song'][$i]['SongGenreParentID'];
    
$SongGenreTopParentID = $GetArtistSongs['SongList'][0]['Song'][$i]['SongGenreTopParentID'];
    
$SongGenreName = $GetArtistSongs['SongList'][0]['Song'][$i]['SongGenreName'];
    
$SongParentGenreName = $GetArtistSongs['SongList'][0]['Song'][$i]['SongParentGenreName'];
    
$SongTopParentGenreName = $GetArtistSongs['SongList'][0]['Song'][$i]['SongTopParentGenreName'];
    
$PlayChartGenrePos = $GetArtistSongs['SongList'][0]['Song'][$i]['PlayChartGenrePos'];
    
$PlayChartParentGenrePos = $GetArtistSongs['SongList'][0]['Song'][$i]['PlayChartParentGenrePos'];
    
$PlayChartTopParentGenrePos = $GetArtistSongs['SongList'][0]['Song'][$i]['PlayChartTopParentGenrePos'];
    
$PlayChartAllGenresPos = $GetArtistSongs['SongList'][0]['Song'][$i]['PlayChartAllGenresPos'];
    
$DownloadChartGenrePos = $GetArtistSongs['SongList'][0]['Song'][$i]['DownloadChartGenrePos'];
    
$DownloadChartParentGenrePos = $GetArtistSongs['SongList'][0]['Song'][$i]['DownloadChartParentGenrePos'];
    
$DownloadChartTopParentGenrePos = $GetArtistSongs['SongList'][0]['Song'][$i]['DownloadChartTopParentGenrePos'];
    
$DownloadChartAllGenresPos = $GetArtistSongs['SongList'][0]['Song'][$i]['DownloadChartAllGenresPos'];
?>
    <p><strong>Entry No. <? echo $i+1; ?></strong></p>
    <li>Mp3 ID: <? echo $Mp3ID; ?></li>
    <li>Song Title: <? echo $SongTitle; ?></li>
    <li>Composer: <? echo $Composer; ?></li>
    <li>Lyrics Author: <? echo $LyricsAuthor; ?></li>
    <li>Distribution: <? echo $Distribution; ?></li>
    <li>Performing Rights Organization: <? echo $PerformingRightsOrganization; ?></li>
    <li>Performing Rights Organization ID: <? echo $PerformingRightsOrganizationID; ?></li>
    <li>Other Performing Rights Organization: <? echo $OtherPerformingRightsOrganization; ?></li>
    <li>Song Price: <? echo $SongPrice; ?></li>
    <li>Year: <? echo $Year; ?></li>
    <li>Song Label: <? echo $SongLabel; ?></li>
    <li>Song Picture Exists: <? echo $SongPictureExists; ?></li>
    <li>Song Lyrics: <? echo $SongLyrics; ?></li>
    <li>LoFi Exists: <? echo $LoFiExists; ?></li>
    <li>HiFi Exists: <? echo $HiFiExists; ?></li>
    <li>Download Exists: <? echo $DownloadExists; ?></li>
    <li>File Size: <? echo $FileSize; ?></li>
    <li>Upload Date: <? echo $UploadDate; ?></li>
    <li>Song Genre ID: <? echo $SongGenreID; ?></li>
    <li>Song Genre Parent ID: <? echo $SongGenreParentID; ?></li>
    <li>Song Genre Top Parent ID: <? echo $SongGenreTopParentID; ?></li>
    <li>Song Genre Name: <? echo $SongGenreName; ?></li>
    <li>Song Parent Genre Name: <? echo $SongParentGenreName; ?></li>
    <li>Song Top Parent Genre Name: <? echo $SongTopParentGenreName; ?></li>
    <li>Play Chart Genre Pos: <? echo $PlayChartGenrePos; ?></li>
    <li>Play Chart Parent Genre Pos: <? echo $PlayChartParentGenrePos; ?></li>
    <li>Play Chart Top Parent Genre Pos: <? echo $PlayChartTopParentGenrePos; ?></li>
    <li>Play Chart All Genres Pos: <? echo $PlayChartAllGenresPos; ?></li>
    <li>Download Chart Genre Pos: <? echo $DownloadChartGenrePos; ?></li>
    <li>Download Chart Parent Genre Pos: <? echo $DownloadChartParentGenrePos; ?></li>
    <li>Download Chart Top Parent Genre Pos: <? echo $DownloadChartTopParentGenrePos; ?></li>
    <li>Download Chart All Genres Pos: <? echo $DownloadChartAllGenresPos; ?></li>
    <?
    
}
?>
</ul>
</span>