iTunes Search API - HTTPS artworkUrl?

时间:2013-03-01 02:48:38

标签: api itunes

当我通过SSL对iTunes Search API运行查询时,返回的大部分URL都是通过HTTPS提供的:

https://itunes.apple.com/search?term=rihanna

但是,artUrl结果是通过HTTP提供的,并且手动更新它们会引发错误,因为SSL证书与他们正在使用的域不匹配。

有没有办法通过HTTPS而不是HTTP来获取这些图像?

3 个答案:

答案 0 :(得分:10)

答案 1 :(得分:3)

iTunes不支持基于HTTPS的专辑封面或歌曲预览(尚未)。

最近(仅四个月前)工具和HTTPS链接的转换: http://www.apple.com/itunes/affiliates/resources/blog/secure-links-to-itunes---content-and-tools.html

答案 2 :(得分:0)

SO和Swift的新手 - 在找到这个Q以及上面的答案之前偶然发现了这个问题。以下对我有用:

func withHTTPS() -> URL? {
  var components = URLComponents(url: self, resolvingAgainstBaseURL: true)
  components?.scheme = "https"
  let host = (components?.host)!
  components?.host = host.replacingOccurrences(of: ".", with: "-ssl.", options: .caseInsensitive, range: host.range(of: "."))
  return components?.url
}

使用:

调用
guard let url = item.artworkURL.withHTTPS() else { return }
相关问题