我试图从iTunes搜索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
从阅读文档和其他一些帖子,这是我认为它应该如何工作,但它没有。有人能帮我吗?谢谢。
我认为你需要做的是获取提要URL并直接从那里获取轨道
"feedUrl":"http://jovemnerd.com.br/categoria/nerdcast/feed/",
我怀疑iTunes搜索API文档和实现包含没有写清楚的警告。
对我来说,这行得通。我使用这个代码: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);