opentaobao

package module
v0.0.0-...-588226b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 17 Imported by: 0

README

taobaogo

淘宝Api、淘宝开放平台Api请求基础SDK

淘宝API

sign算法

淘宝Session

Example 🌰

package main

import (
	"fmt"

	 "github.com/nilorg/go-opentaobao"
)

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"])
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AppKey 应用Key
	AppKey string
	// AppSecret 秘密
	AppSecret string
	// Router 环境请求地址
	Router = "http://gw.api.taobao.com/router/rest"
	// Session 用户登录授权成功后,TOP颁发给应用的授权信息。当此API的标签上注明:“需要授权”,则此参数必传;“不需要授权”,则此参数不需要传;“可选授权”,则此参数为可选
	Session string
	// Timeout ...
	Timeout time.Duration
	//API Version ...
	V = "2.0"
	// CacheExpiration 缓存过期时间
	CacheExpiration = time.Hour
	// GetCache 获取缓存
	GetCache cache.GetCacheFunc
	// SetCache 设置缓存
	SetCache cache.SetCacheFunc
)
View Source
var (
	ErrTypeIsNil   = errors.New("类型为Nil")
	ErrTypeUnknown = errors.New("未处理到的数据类型")
)

Functions

func Execute

func Execute(method string, param Parameter) (res *simplejson.Json, err error)

Execute 执行API接口

func ExecuteCache

func ExecuteCache(method string, param Parameter) (res *simplejson.Json, err error)

ExecuteCache 执行API接口,缓存

Types

type Parameter

type Parameter map[string]interface{}

Parameter 参数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL