简体   繁体   English

Spotify Web JS包装器发布多个曲目(不是来自播放列表)

[英]Spotify Web JS wrapper-posting multiple tracks (not from playlist)

I am attempting to use the Spotify Web API JS wrapper from the following repo: 我正在尝试从以下存储库中使用Spotify Web API JS包装器:

https://github.com/JMPerez/spotify-web-api-js https://github.com/JMPerez/spotify-web-api-js

My goal here is to pull multiple tracks from Spotify and print them to a playlist on a webpage.The final version would ideally display up to 15 tracks at a time. 我的目标是从Spotify中提取多首曲目并将其打印到网页上的播放列表中。理想情况下,最终版本一次最多可显示15首曲目。 Would this require an individual 这需要一个人吗

  • for each? 每个? I'm pretty new to using API's so I will display the relevant JS and HTMl below for reference. 我对使用API​​很陌生,因此我将在下面显示相关的JS和HTMl以供参考。 Thank you for your help! 谢谢您的帮助!

      var spotifyApi= new SpotifyWebApi(); //access token (optional) spotifyApi.setAccessToken(); Constr.prototype.getTracks = function(trackIds, options, callback) { var requestData = { url: _baseUri + '/tracks/', params: { ids: trackIds.join(',') } }; return _checkParamsAndPerformRequest(requestData, options, callback); }; 

    HTML 的HTML

     <div class="playlist"> <p>Upload of tracks requires valid Spotify account</p> <a href="https://www.spotify.com/us/signup/">Sign up here</a> <div class="search"> <input type="search"> <p>Enter Artist Here</p> </div> <ul> <li type='none'id="tracks"> </li> </ul> </div><!--playlist--> 
  • There is an endpoint in the Spotify Web API for fetching multiple tracks at the same time that accepts an ids query parameter with comma separated track ids. Spotify Web API中一个端点用于同时获取多个轨道,该端点接受带有逗号分隔的轨道ID的ids查询参数。 That is the endpoint used in the getTracks() function of the wrapper you are using. 那就是您正在使用的包装器的getTracks()函数中使用的端点。

    From your question, I don't really know if you want to add those tracks to a playlist or if you want to render tracks from an artist. 从您的问题来看,我真的不知道您是否要将这些曲目添加到播放列表中,或者是否要渲染艺术家的曲目。

    If you want to create a playlist with some tracks you will need the user to authorize your app. 如果您想创建包含某些曲目的播放列表,则需要用户授权您的应用。 You have more information on the Authorization Guide . 您可以在“ 授权指南”中获得更多信息。

    If you want to render tracks by an artist, you can also use some other endpoints like the one for getting an artist's top tracks . 如果要由艺术家渲染轨道,还可以使用其他一些端点,例如获取艺术家的顶级轨道的端点。

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM