-6
我正在嘗試使用ASP.NET MVC 4和C#構建一個網站,以使用Spotify web api搜索音樂藝術家的前5個專輯。如何從Spotify Web API獲取藝術家的前5個專輯?
這是到目前爲止我的代碼:
public ActionResult Result(string Artist)
{
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("https://api.spotify.com/");
// what goes here to authenticate and get the info?
return View();
}
我找不到,告訴我如何進行身份驗證,然後使用C#檢索信息。
編輯:我應該提到,我是這個東西的絕對初學者,雖然我讀過spotify API參考,但它並沒有幫助我,因爲它沒有解釋足夠的細節。
例如,web api用戶指南討論GET,POST等,但沒有給出任何代碼來幫助解釋如何使用它。在那裏唯一的代碼是:
$ curl -H "Authorization: Basic Yjc...cK" -d grant_type=refresh_token -d refresh_token=AQD...f0 "https://accounts.spotify.com/api/token"
{
"error": "invalid_client",
"error_description": "Invalid client secret"
}
這是令人困惑的我,因爲我不知道放在哪裏,我不知道用什麼語言代碼等
有沒有C#示例,我可以找到。即使這些代碼示例都是javascript,但它並不能幫助我。
爲何不看看Spotify的API文檔? https://developer.spotify.com/web-api/endpoint-reference/ –
我沒有...它沒有幫助。 – zachboy82
你提到你閱讀文檔,但它沒有幫助,因爲它「*沒有解釋足夠的細節*」。如果是這樣的話,爲什麼不問一個關於你不明白的問題*特別是*? –