前段时间看了些GoLang的资料,要上手熟悉就得造轮子,so.. 造了个GoLang版本的有赞云SDK。
Talk is cheap. Show me the code…
- GitHub: https://github.com/xu42/youzan-sdk-go
- GoDoc: https://godoc.org/github.com/xu42/youzan-sdk-go
GoLang写出来确实简洁,总共也没多少行代码…
使用
这里仅举例获取Token和调用示例API
- 生成Token
package main
import (
"fmt"
"github.com/xu42/youzan-sdk-go"
)
func main() {
// 获取自用型AccessToken
resp, err := youzan.GenSelfToken("CLIENT_ID", "CLIENT_SECRET", "110")
fmt.Println(resp, resp.AccessToken, err)
// 获取自用型AccessToken
resp1, err1 := youzan.GenToolToken("CLIENT_ID", "CLIENT_SECRET", "CODE", "URI")
fmt.Println(resp1, resp1.AccessToken, err1)
}
- 调用API
package main
import (
"fmt"
"github.com/xu42/youzan-sdk-go"
)
func main() {
params := map[string]string{
"page_no": "1",
"page_size": "10",
}
result, err := youzan.Call("ACCESS_TOKEN", "youzan.scrm.customer.search", "3.1.0", params)
fmt.Println(result, err)
}
有什么问题可以留言交流