Connecting Spotify API with Google Sheets



我正试图找到一种更稳定的方式来提取Spotify数据到谷歌表。我需要各种数据,如播放列表关注者/喜欢,艺术家关注者和每月听众。

现在我有办法做到这一切。使用importXML和JSON。参考- FetchingURL使用JSON在谷歌表v2

我想使用Spotify API作为更可靠的方式来获得这些数字。然而,我甚至不知道如何开始。我一直在看这个网站- https://developer.spotify.com/documentation/web-api/reference/#/,我只是不知道该怎么做。

任何指导或参考链接将非常感激!

谢谢,罗伯特。

您可以从了解Spotify Web API授权的一般指南开始。

这需要一个Web应用程序,因为您需要从Spotify API中提取的大多数信息(例如播放列表关注者/喜欢,艺术家关注者和每月听众)不是基本请求URI的公开信息。

下面是客户端凭证OAuth流程的示例:

var request = require('request'); // "Request" library
var client_id = 'CLIENT_ID'; // Your client id
var client_secret = 'CLIENT_SECRET'; // Your secret
// your application requests authorization
var authOptions = {
url: 'https://accounts.spotify.com/api/token',
headers: {
'Authorization': 'Basic ' + (new Buffer(client_id + ':' + client_secret).toString('base64'))
},
form: {
grant_type: 'client_credentials'
},
json: true
};
request.post(authOptions, function(error, response, body) {
if (!error && response.statusCode === 200) {
// use the access token to access the Spotify Web API
var token = body.access_token;
var options = {
url: 'https://api.spotify.com/v1/users/jmperezperez',
headers: {
'Authorization': 'Bearer ' + token
},
json: true
};
request.get(options, function(error, response, body) {
console.log(body);
});
}
});

您可以登录到您的Spotify开发者仪表板在这里生成您的客户端ID和客户端秘密在创建所需的身份验证流程的应用程序环境。您可以查看Spotify的Web API教程

引用:

https://github.com/spotify/web-api-auth-examples/blob/master/client_credentials/app.jshttps://developer.spotify.com/documentation/general/guides/authorization/code-flow/https://developer.spotify.com/documentation/web-api/quick-start/

最新更新