<?

/************************************************************************
*
*                  OMS Web Service Functions 1.4
*                  -----------------------------
*
*     Copyright:   (C) 2007 moving primates GmbH
*      Function:   GetArtistRating
*   Description:   Gets all rating information of one artist.
*   Change Date:   12/Jun/2007
*
*************************************************************************
*
*   REQUIRED ELEMENTS:
*
*   The following elements must be send with the request:
*
*   - ArtistID  < value must be numeric
*   - UserID    < should be read out from cookie to prevent double rating
*
*   FIELD ELEMENTS: None
*
*************************************************************************
*   More info about elements and the functions can be found inside
*   the documentation.
************************************************************************/

$ArtistID = "35748"; // Example ID from an artist
include("inc/config.php"); // Eexample 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'] . "/GetArtistRating");


// Here we are defining the REQUIRED elements

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

$el_user_id = create_element($dom, "UserID");
set_element_value($dom, $el_user_id, "0");


// Preparing the XML which is going to be send

add_child_element($root, $el_artist_id);
add_child_element($root, $el_user_id);

$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 "GetArtistRating"

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


/************************************************************************
*
*   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;35748&quot;, an example ID from an artist</li>
    <li><em>UserID</em> - value was &quot;0&quot;</li>
</ul>
<br />
<strong>We got back the following array in <u>RESPONSE</u>:</strong><br />
<pre><? var_dump($GetArtistRating); ?>
</pre>
<br />
<strong>We assign the array to  seperate variables and <u>OUTPUT</u> these (without any design here):</strong><br />
<?
    $ArtistID
= $GetArtistRating['ArtistID'][0];
    
$RatingCount = $GetArtistRating['RatingCount'][0];
    
$AvgRating = $GetArtistRating['AvgRating'][0];
    
$UserID = $GetArtistRating['UserID'][0];
    
$UserRating = $GetArtistRating['UserRating'][0];
?>
<ul>
    <li>Artist ID: <? echo $ArtistID; ?></li>
    <li>Rating Count: <? echo $RatingCount; ?></li>
    <li>Average Rating: <? echo $AvgRating; ?></li>
    <li>User ID: <? echo $UserID; ?></li>
    <li>User Rating: <? echo $UserRating; ?></li>
</ul>
</span>