Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用艺术家和标题查询Amazon产品API以获取MP3下载ASIN_Php_Amazon Product Api - Fatal编程技术网

Php 使用艺术家和标题查询Amazon产品API以获取MP3下载ASIN

Php 使用艺术家和标题查询Amazon产品API以获取MP3下载ASIN,php,amazon-product-api,Php,Amazon Product Api,我是新使用亚马逊的产品广告API的,在我的第一个项目中,我试图获得一首特定歌曲的MP3下载产品的ASIN,基于艺术家和标题。我最终将使用这些ASIN来填充一个 我正在使用开始。它工作正常,我添加了以下功能: public function searchMusic($artist, $title) { $parameters = array("Operation" => "ItemSearch", "Ar

我是新使用亚马逊的产品广告API的,在我的第一个项目中,我试图获得一首特定歌曲的MP3下载产品的ASIN,基于艺术家和标题。我最终将使用这些ASIN来填充一个

我正在使用开始。它工作正常,我添加了以下功能:

    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;
    }
现在,问题是,我似乎只能这样得到专辑。例如,如果我把“罗伯特·兰多夫”作为艺术家,把“色盲”作为标题,我会得到罗伯特·兰多夫和这个家庭乐队的色盲专辑。如果我搜索某个特定的曲目,比如《It的惊险》,亚马逊什么也找不到

所以我需要做的是首先找出如何查询曲目标题。然后我需要弄清楚如何将我的结果限制在MP3下载。我该怎么做

如果有关于这个主题的文档,你能为我指出正确的方向吗?我去过,但没有看到我想要的任何参数


感谢您抽出时间。

文档组织得很奇怪,我自己也很难找到相关信息

要查找MP3,必须将
SearchIndex
参数更改为“MP3Downloads”。然后,你必须使用“关键词”,而不是使用“艺术家”和“轨迹”。将艺术家值和轨迹值合并为“关键字”属性值的一个字符串。另外,对于
SearchIndex
,请尝试使用“MusicTracks”,因为您可能会在那里得到不同的结果

这是我拥有的一个工作系统中的一个片段,它执行类似类型的查找

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

这也是我的一个问题。我使用了同一个示例,对其进行了大量修改,并将其合并到我制作mashup的整个类集合中。我真正想要的是亚马逊提供的艺术家和专辑名称的预览。既然我还有太多的时间,我会继续努力的。我的mashup代码库在这里:

我不断从这个问题中获得推荐,我的解决方案与Chris的基本相同,我的代码中有两个方法/函数可以实现这一点:

        /**
     * 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更适合用于歌曲预览。

您好。如何只在原始曲目上搜索?我已经多年没有使用过那个API了。亚马逊、谷歌和其他公司更改了API以及允许的内容。我甚至不知道你说的原创歌曲是什么意思,整首歌?亚马逊不会让你访问整首歌,他们几乎不可能访问预览版。Thks来获取你的答案。我改进了你的帖子,ans将版本改为2013。。。而且它工作得很好;)。最初,我想说“官方发布”,就像它是在musicbraiz或discogs php api中命名的。对我来说,现在我需要更新我的GData代码,我不想使用Zend,我只有一个方法,为什么我需要向我的项目添加这么多代码…不明白你想要什么吗?