taobaojingdong

package module
v0.0.0-...-f932754 Latest Latest
Warning

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

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

README

taobaogo

淘宝客,京东Api、淘宝开放平台Api,京东联盟请求基础SDK

淘宝API

sign算法

淘宝Session

Example

package main

import (
	"fmt"
	 "gitee.com/vblant/go-taobaojingdong"
)

func init() {
	taobaojingdong.AppKey = ""
	taobaojingdong.AppSecret = ""
	taobaojingdong.Router = "http://gw.api.taobao.com/router/rest"
}

func main() {
	res, err := taobaojingdong.Execute("taobao.tbk.dg.material.optional", taobaojingdong.Parameter{
		"adzone_id":"",
		"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 (
	// 请求平台(1=taobao,2=jingdong.默认1)
	Platform string
	// 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