英文:
Looking for Starter Resources for the Soundcloud API in GoLang
问题
我尝试使用Go访问Soundcloud API,但没有成功。对于任何不直接支持的语言,他们的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
}
希望对你有帮助!
英文:
I've unsuccessfully tried to access the Soundcloud API with Go. For any language that isn't directly support by Soundcloud, their API is very convoluted. If anyone has any resources or code examples, I'd appreciate it if someone shared them with me.
My code is as follows:
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
}
答案1
得分: 1
我正在开发一个用于访问和处理Soundcloud API的Go语言包,它支持OAuth2,并且已经可以使用。
我邀请你去查看它。https://github.com/njasm/gosoundcloud
请注意,该包仍在积极开发中,API可能会在将来发生变化。
英文:
i'm active developing a package in go to access/work with Soundcloud API, it has OAuth2 support, and is already usable.
I invite you to look for it. https://github.com/njasm/gosoundcloud
Take in consideration that the package is still under heavy development, the API might change in the future.
答案2
得分: 0
你可以查看yanatan16/golang-soundcloud,尽管认证部分尚未实现(请参阅问题)。
不过,有一个oauth类。还有很多其他调用API的方法,用于获取SoundCloud对象。
英文:
You can have a look at yanatan16/golang-soundcloud, even though then authentication part isn't implemented yet (see issues)
There is an oauth class though.
Ad quite a few other calls to the API, for getting SoundCloud objects.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论