Create Affiliate ID
Code samples below do not contain a valid Affiliate ID. Create an Affiliate account before using these.
Real sample code:
- PHP class to use our webservice View and download
- Top 10 View in action and download
- Search View in action and download
- Artist List View in action and download
Copied!
<?php
require_once(__DIR__ . '/KVService.php');
// Query to get the Top 10 Songs
$top10Query = array(
"function" => "list",
"parameters" => array(
"limit" => 10
)
);
// Get the songs back form the service
$top10 = KVService::querySong($top10Query);
header("Content-Type: text/html; charset=UTF-8");
// Display the top
echo '<h1>Top 10 Songs</h1>';
echo "<ol>";
foreach ($top10->songs as $song) {
// Get the artist of the song
$queryArtist = array(
"function" => "get",
"parameters" => array("id" => $song->artistId)
);
$artist = KVService::queryArtist($queryArtist)->artist;
echo '<li>
<a href="' . $song->url . '">' . $artist->name . ' - ' . $song->name . '</a> | <a href="' . $song->previewUrl . '">Preview</a>
</li>';
}
echo "</ol>";