【JAVASCRIPT】使用secret_token從私有(private)播放列表流式播放曲目會生成404

2021-01-12 JAVASCRIPT

從專用播放列表中流式播放私人曲目,使用它的父播放列表的祕密令牌可以正常工作。現在它會生成一個404。這開始發生在2016年12月7日。我正在使用SoundCloud的js sdk v3.1.2

為了澄清起見,我使用的是從stream_url端點返回的曲目的playlists/。在這種情況下,播放列表的secret_token是s-6AMBa,以及該播放列表中每個曲目的secret_token。下面的程式碼是我如何從該私人播放列表中流式播放一首曲目。

SC.initialize({
    client_id: [clientid],
    redirect_uri: [redirect_uri]
});
SC.stream('/tracks/296005694', 's-6AMBa').then(function(data) {
    data.play();
}).catch(function(error) {
    alert('Error! ' + error.message);
});


錯誤:

https://api.soundcloud.com/tracks/296005694?secret_token=s-6AMBa&format=json&client_id=[clientid]
Failed to load resource: the server responded with a status of 404 (Not Found)


錯誤中的該連結將產生404,但此輕微調整(在軌道ID之後新增/stream)可以正確解決。

https://api.soundcloud.com/tracks/296005694/stream?secret_token=s-6AMBa&format=json&client_id=[clientid]`


就像我提到的那樣,該系統已經為我工作了多年,直到最近才開始生成404。還有其他人有這個問題嗎?播放列表祕密令牌方面最近有什麼變化嗎?

解決辦法

docs中所述,如果您想通過播放列表的端點返回音訊流,則相應的URI是

[soundcloud url="https://api.soundcloud.com/playlists/282919801/stream?secret_token=s-EqJoD&client_id=[clientid]"]


並訪問單個軌道的端點,則相應的URI是

[soundcloud url="https://api.soundcloud.com/tracks/276344823/stream?secret_token=s-EqJod&client_id=[clientid]"]

出處

Have any Question?

Let us answer it!