GO语言、淘宝Api、淘宝开放平台Api请求基础SDK
dkeng/opentaobao-gogithub.com
淘宝API sign算法dkeng/opentaobao-go淘宝API sign算法
package main
import (
"fmt"
"github.com/dkeng/opentaobao-go"
)
func init() {
opentaobao.AppKey = ""
opentaobao.AppSecret = ""
opentaobao.Router = "http://gw.api.taobao.com/router/rest"
}
func main() {
res, err := opentaobao.Execute("taobao.tbk.item.get", opentaobao.Parameter{
"fields": "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url,seller_id,volume,nick",
"q": "女装",
"cat": "16,18",
})
if err != nil {
fmt.Println(err)
}
fmt.Println("商品数量:", res.Get("tbk_item_get_response").Get("total_results").MustInt())
var imtes []interface{}
imtes, _ = res.Get("tbk_item_get_response").Get("results").Get("n_tbk_item").Array()
for _, v := range imtes {
fmt.Println("======")
item := v.(map[string]interface{})
fmt.Println("商品名称:", item["title"])
fmt.Println("商品价格:", item["reserve_price"])
fmt.Println("商品链接:", item["item_url"])
}
}
本文展示了一个使用GO语言调用淘宝开放平台API的基础示例,通过dkeng/opentaobao-go SDK实现对淘宝商品信息的获取。代码示例中详细介绍了如何设置AppKey、AppSecret及Router,并演示了如何执行API请求,解析返回结果,打印商品名称、价格及链接。
3616

被折叠的 条评论
为什么被折叠?



