2011-12-25 44 views
0

我想獲取包含用戶庫中所有播放列表的數組(http://developer.spotify.com/download/spotify-apps-api/參考/ dcdebc652c.html)。Spotify應用程序API:圖書館級不會返回用戶播放列表

沒有問題與其他類的屬性(專輯,藝術家,starredPlaylist,軌道),但不知何故,在 「播放列表」 屬性不會使用

var allPlaylists = models.library.playlists; 

var allArtists= models.library.artists; 

作品只是工作(兩者都使用document.write(var))

有什麼建議嗎?謝謝!

+1

你是什麼意思的「不行」?它拋出一個錯誤在你的控制檯或是一個空的數組或null或什麼? – Trott 2011-12-25 00:33:24

+0

對不起,document.write返回「undefined」 – 2011-12-25 10:54:13

回答

0

我在想這是一個API的錯誤。

sp = getSpotifyAPI(1); 
models = sp.require('sp://import/scripts/api/models') 
models.library.playlists; 

> TypeError: Cannot read property 'length' of undefined 

try { models.library.playlists } catch(err) { console.log(err.stack) } 

> TypeError: Cannot read property 'length' of undefined 
    at map (sp:216:20) 
    at Library.<anonymous> (eval at evalModule (sp:55:46)) 
    at unknown source 
    at Object._evaluateOn (unknown source) 
    at Object._evaluateAndWrap (unknown source) 
    at Object.evaluate (unknown source) 

在models.js文件挖我們看到,圖書館使用sp.core.library.getPlaylists()來獲取播放列表,這應該返回一個數組,但返回未定義:

sp.core.library.getPlaylists() 

> undefined 

sp.core.library.getPlaylists 

> function getPlaylists() { [native code] } 

由於sp.core.library.getPlaylists是本機代碼,我無法深入兔子洞看它在做什麼。所以除非spotify開發者說這是期望的行爲,否則我的結論是它是一個bug。

+0

謝謝隊友!我看起來像sp.core.library.getPlaylists被禁用。 [0.8.0-701-gc2d793a](http://developer.spotify.com/download/spotify-apps-api/guidelines/04_changelog.html) 但未提及原因:S – 2011-12-25 17:58:49

+0

獲取用戶的播放列表不是支持我們的API。 – mager 2012-01-11 16:36:11

2

下面是官方的回答:

不幸的是,要獲得用戶的播放列表Spotify的應用程序API中的能力已經對隱私的原因除去。這是在最後一刻完成的,文件沒有及時更新。我們將發佈新版本的客戶和文檔,以儘快反映這一變化。

+0

這裏的任何更新重新:通過api返回用戶的播放列表?有一陣子了! – samthebrand 2014-10-11 02:29:20

相關問題