Amazon API request to download ASIN in MP3 format using artist and title

I am using the Amazon Product Advertising API, and for my first project with it, I am trying to get the ASIN of a specific MP3 song download file based on the artist and title. Ultimately, I will use these ASINs to populate the Amazon MP3 Clips Widget .

I am using the PHP class from CodeDiesel.com to get started. It works fine, and I added the following function:

    public function searchMusic($artist, $title) {
        $parameters = array("Operation"     => "ItemSearch",
                            "Artist"        => $artist,
                            "Title"         => $title,
                            "SearchIndex"   => "Music",
                            "ResponseGroup" => "Medium");
        $xml_response=$this->queryAmazon($parameters);
        return $xml_response;
    }

Now, the trouble is that I can just get albums. For example, if I put “Robert Randolph” for the artist and “Colorblind” for the title, I get Robert Randolph and the Family Band Colorblind album. If I’m looking for a specific track, such as “Thrill Of It,” Amazon cannot find anything.

So, I need to first figure out how to make a query for the name of the track. Then I need to figure out how to limit my results to just downloading MP3s. How can i do this?

If there is documentation on this topic, can you point me in the right direction? I read through it , but I don’t see any parameters for what I want.

Thank you for your time.

+5
source share
2 answers

, .

mp3, SearchIndex "MP3Downloads". "Artist" "Track" " ". " ". , "MusicTracks" SearchIndex, .

, .

    $params = Array(
        "Operation"=>'ItemSearch',
        "SearchIndex"=>'MP3Downloads',
        "ResponseGroup"=>'ItemAttributes,Tracks,Images',
        "Keywords"=>$track['title'].' '.$artist['name']
    );
+9

, . , , mashups. , Amazon . , , . mashup :

Mashup

, , , /, :

        /**
     * Return the tracks found on an album, have to page to get them all which this method does not do.
     * 
     * @param string $albumTitle 
     * @param string $artist
     * @return mixed simpleXML object
     */
    public function getMP3sForAlbumByArtist($albumTitle, $artist)
    {
        $searchTerm = $albumTitle . ' ' . $artist;
        $parameters = array("Operation"   => "ItemSearch",
                            "Keywords"    => $searchTerm,
                            "SearchIndex" => AmazonProductAPI::CATEGORY_MP3_DOWNLOADS,
                            "ResponseGroup" => AmazonProductAPI::RESPONSE_GROUP_TRACKS);

        $xml_response = $this->queryAmazon($parameters);

        return $xml_response;
    }



    /**
     * Return the tracks found on a song title and artist
     * 
     * @param string $songTitle 
     * @param string $artist
     * @return mixed simpleXML object
     */
    public function getMP3ForSongByArtist($songTitle, $artist)
    {
        $searchTerm = $songTitle . ' ' . $artist;
        $parameters = array("Operation"   => "ItemSearch",
                            "Keywords"    => $searchTerm,
                            "SearchIndex" => AmazonProductAPI::CATEGORY_MP3_DOWNLOADS,
                            "ResponseGroup" => AmazonProductAPI::RESPONSE_GROUP_TRACKS);

        $xml_response = $this->queryAmazon($parameters);

        return $xml_response;
    }

GitHub, , . , iTunes .

+2

All Articles