當我運行對iTunes搜索API通過SSL進行查詢,大部分的URL返回都通過HTTPS提供:iTunes搜索API - HTTPS artworkUrl?
https://itunes.apple.com/search?term=rihanna
然而,artworkUrl結果通過HTTP和更新它們手動拋出一個錯誤因爲SSL證書在他們使用的域上不匹配。
有沒有辦法通過HTTPS而不是HTTP獲取這些圖片?
當我運行對iTunes搜索API通過SSL進行查詢,大部分的URL返回都通過HTTPS提供:iTunes搜索API - HTTPS artworkUrl?
https://itunes.apple.com/search?term=rihanna
然而,artworkUrl結果通過HTTP和更新它們手動拋出一個錯誤因爲SSL證書在他們使用的域上不匹配。
有沒有辦法通過HTTPS而不是HTTP獲取這些圖片?
iTunes不支持HTTPS(尚未)的專輯封面或歌曲預覽。
過的工具,並鏈接到HTTPS的變化是最近(僅在四個月前): http://www.apple.com/itunes/affiliates/resources/blog/secure-links-to-itunes---content-and-tools.html
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 }
它已經好幾年,因爲這個答案被接受 - 有什麼變化嗎? – 2016-10-27 00:31:36
它看起來不像。我來這裏試圖找到使用ATP的應用程序中使用的https鏈接。 – Darren 2017-03-07 14:17:37