我尝试使用 Go 访问 Soundcloud API 但未成功。对于 Soundcloud 不直接支持的任何语言,它们的 API 都非常复杂。如果有人有任何资源或代码示例,如果有人与我分享,我将不胜感激。
我的代码如下:
func main() {
v := url.Values{}
v.Set("scope", "non-expiring")
v.Set("client_id", auth.ClientID)
v.Set("response_type", "code")
v.Set("redirect_uri", auth.RedirectURI)
c.AuthURL = AuthEndpoint + "?" + v.Encode()
c.Values = v.Encode()
res := c.Request("POST", url.Values{})
}
func (c *Client) Request(method string, params url.Values) []byte {
params.Set("client_id", "*************")
reqUrl := "https://api.soundcloud.com/oauth2/token"
req, _ := http.NewRequest(method, reqUrl, strings.NewReader(c.Values))
req.Header.Add("Accept", "application/json")
resp, _ := c.client.Do(req)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
return body
}
最佳答案
我正在积极开发一个包来访问/使用 Soundcloud API,它支持 OAuth2,并且已经可用。
我邀请你去寻找它。 https://github.com/njasm/gosoundcloud
考虑到该包仍在大量开发中,API 将来可能会发生变化。
关于rest - 在 GoLang 中寻找 Soundcloud API 的入门资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25213449/