Download and install it:
$ go get -u github.com/ChinaArJun/tksdk
Import it in your code:
import "github.com/ChinaArJun/tksdk/tbopensdk"
Examples
//初始化TopClient
client := &TopClient{}
client.Init(appKey, appSecret, sessionKey)
//初始化请求接口信息
getRequest := &request2.TbkItemInfoGetRequest{}
getRequest.AddParameter("num_iids", "640057354722")
getRequest.AddParameter("platform", "1")
getRequest.AddParameter("ip", "11.22.33.43")
getRequest.AddParameter("get_topn_rate", "1")
//初始化结果类型
var getResponse DefaultResponse = &tbkiteminfoget.Response{}
//执行请求接口得到结果
err := client.Exec(getRequest, getResponse)
if err != nil {
t.Log(err)
} else {
result := getResponse.(*tbkiteminfoget.Response)
if result.IsError() {
fmt.Println(result.Body)
} else {
items := result.TbkItemInfoGetResult.Results.NTbkItem
for _, v := range items {
fmt.Println(v.Title)
}
}
}