我在Spotify的開發人員應用程序部分中創建了一個客戶端ID和密鑰。我引用這個文件並想通過選擇多個藝術家來擴展它。在R中爲多個藝術家訪問Spotify API
https://www.r-bloggers.com/the-eurovision-2016-song-contest-in-an-r-shiny-app/
在這個例子中,他們只選擇1名藝術家ID,但也有一些漏洞此,
1)你如何獲得藝術家的名字,而不是藝術家ID,因爲我可以」 t找到藝術家ID的任何地方的詞彙表鍵?
2)你如何選擇多個藝術家而不是一個。
例如,我該如何選擇Frank Sinatra和Elvis Presley?
代碼如下:
library(httr)
clientID = '#############################'
secret = '########################'
response = POST(
'https://accounts.spotify.com/api/token',
accept_json(),
authenticate(clientID, secret),
body = list(grant_type = 'client_credentials'),
encode = 'form',
verbose()
)
mytoken = content(response)$access_token
## Frank Sinatra spotify artist ID
artistID = '1Mxqyy3pSjf8kZZL4QVxS0'
HeaderValue = paste0('Bearer ', mytoken)
URI = paste0('https://api.spotify.com/v1/artists/', artistID)
response2 = GET(url = URI, add_headers(Authorization = HeaderValue))
Artist = content(response2)
Artist
我在這裏的目標是讓所有有關每個藝術家的歌曲,如danceability屬性等
任何幫助將是巨大的,謝謝!
這是偉大的,謝謝 –
我可以問這在一個單獨的職位,但如何你得到的藝術家的歌曲音頻功能?我知道這是參考:https://developer.spotify.com/web-api/get-several-audio-features/,但在R @ Hack-R中使用它很麻煩 –