如何从专辑中获取播客专题节目列表(iTunes Search API)

时间:2014-05-18 01:05:14

标签: itunes-search-api

我试图从iTunes Search API获取播客剧集列表。我可以拨打API并根据搜索字词取回所有播客专辑:

https://itunes.apple.com/search?media=podcast&term=nerdcast

返回以下json(裁剪):

{
"resultCount": 20,
"results": [
    {
        "wrapperType": "track",
        "kind": "podcast",
        "collectionId": 381816509,
        "trackId": 381816509,
        "artistName": "Nerdcast",
        "collectionName": "Nerdcast",
        "trackName": "Nerdcast",
        "collectionCensoredName": "Nerdcast",
        "trackCensoredName": "Nerdcast",
        "collectionViewUrl": "https://itunes.apple.com/us/podcast/nerdcast/id381816509?mt=2&uo=4",
        "feedUrl": "http://jovemnerd.com.br/categoria/nerdcast/feed/",
        "trackViewUrl": "https://itunes.apple.com/us/podcast/nerdcast/id381816509?mt=2&uo=4",
        "artworkUrl30": "http://a5.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.30x30-50.jpg",
        "artworkUrl60": "http://a4.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.60x60-50.jpg",
        "artworkUrl100": "http://a1.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.100x100-75.jpg",
        "collectionPrice": 0,
        "trackPrice": 0,
        "trackRentalPrice": 0,
        "collectionHdPrice": 0,
        "trackHdPrice": 0,
        "trackHdRentalPrice": 0,
        "releaseDate": "2014-05-16T12:12:00Z",
        "collectionExplicitness": "notExplicit",
        "trackExplicitness": "notExplicit",
        "trackCount": 301,
        "country": "USA",
        "currency": "USD",
        "primaryGenreName": "Society & Culture",
        "radioStationUrl": "https://itunes.apple.com/station/idra.381816509",
        "artworkUrl600": "http://a2.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.600x600-75.jpg",
        "genreIds": [
            "1324",
            "26"
        ],
        "genres": [
            "Society & Culture",
            "Podcasts"
        ]
    },
.....

我现在想从第一个结果中获取所有剧集。我尝试使用collectionId执行查找请求,但它只返回与上面相同的输出,而不是该集合中的所有播客。

https://itunes.apple.com/lookup?id=381816509&entity=podcast

通过阅读文档和其他一些帖子,我认为它应该如何运作,但它并没有。有人能帮帮我吗?感谢。

2 个答案:

答案 0 :(得分:9)

我认为您需要做的是获取该Feed网址并直接从那里获取曲目

“feedUrl”:“http://jovemnerd.com.br/categoria/nerdcast/feed/”,

我怀疑iTunes搜索API文档和实现包含未明确说明的警告。

答案 1 :(得分:0)

对我来说,这很有效。我用这个代码: https://github.com/ijanerik/PHP-iTunes-API/blob/master/README.md

foreach($results as $item){
$url = $item->feedUrl;
}
$xml = simplexml_load_file($url) or die("feed not loading");
print_r($xml);