opentaobao

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

README

TaoBao SDK Glang

使用示例
1、初始化client
c := opentaobao.New()
c.AppKey = "2526218"
c.AppSecret = "da2e7dd98976df40fae3899afab4bfe"

2、初始化request
req := tbk.OrderDetailsGetRequest()
req.SetStartTime("2020-05-27 11:00:00")
req.SetEndTime("2020-05-27 18:00:00")
req.SetOrderScene(2)

3、执行请求
body, err := c.Exec(req)
if err != nil {
    log.Fatalln(err)
}

4、解析结果
var result tbk.OrderDetailsGetData
result, err = tbk.OrderDetailsGetResult(body)
if err != nil {
    log.Fatalln(err)
}
log.Println(result.Results)
参考
  1. 淘宝开放平台

Documentation

Index

Constants

View Source
const (
	HTTP_GATEWAY           = "http://gw.api.taobao.com/router/rest"
	HTTPS_GATEWAY          = "https://eco.taobao.com/router/rest"
	HTTP_TEST_GATEWAY      = "http://gw.api.tbsandbox.com/router/rest"
	HTTPS_TEST_GATEWAY     = "https://gw.api.tbsandbox.com/router/rest"
	HTTP_OVERSEAS_GATEWAY  = "http://api.taobao.com/router/rest"
	HTTPS_OVERSEAS_GATEWAY = "https://api.taobao.com/router/rest"
	MD5                    = "md5"
	HMAC                   = "hmac"
	XML                    = "xml"
	JSON                   = "json"
)

Variables

View Source
var (
	NIL_TYPE_ERROR     = errors.New("数据类型为nil")
	UNKONWN_TYPE_ERROR = errors.New("未知的数据类型")
	API_RESPONSE_ERROR = errors.New("接口返回错误")
)
View Source
var (
	AppKey    = "2814415"
	AppSecret = "181f90dee3bf06f1c9553f776b52dd9"
)

Functions

func BytesToInt added in v0.0.3

func BytesToInt(data []byte) int

BytesToInt 字节转Int

func BytesToInt32 added in v0.0.3

func BytesToInt32(data []byte) int32

BytesToInt32 字节转Int32

func BytesToInt64 added in v0.0.3

func BytesToInt64(data []byte) int64

BytesToInt64 字节转Int64

func ToBool added in v0.0.3

func ToBool(i interface{}) bool

ToBool 转换成Bool

func ToFloat32 added in v0.0.3

func ToFloat32(value interface{}) float32

ToFloat32 转换成float32

func ToFloat64 added in v0.0.3

func ToFloat64(value interface{}) float64

ToFloat64 转换成float64

func ToInt added in v0.0.3

func ToInt(value interface{}) int

ToInt 转换成int

func ToInt32 added in v0.0.3

func ToInt32(value interface{}) int32

ToInt32 转换成int32

func ToInt64 added in v0.0.3

func ToInt64(value interface{}) int64

ToInt64 转换成int64

func ToString added in v0.0.3

func ToString(value interface{}) string

ToString 转换成string

func ToUint added in v0.0.3

func ToUint(value interface{}) uint

ToUint 转换成uint

func ToUint32 added in v0.0.3

func ToUint32(value interface{}) uint32

ToUint32 转换成uint32

func ToUint64 added in v0.0.3

func ToUint64(value interface{}) uint64

ToUint64 转换成uint64

Types

type Client

type Client struct {
	Gateway      string
	AppKey       string // TOP分配给应用的AppKey
	AppSecret    string // TOP分配给应用的AppSecret
	TargetAppKey string // 被调用的目标AppKey,仅当被调用的API为第三方ISV提供时有效
	SignMethod   string // 签名的摘要算法,可选值为:hmac,md5
	Format       string // 响应格式。默认为xml格式,可选值:xml,json。
	V            string // API协议版本,可选值:2.0
	Session      string // 用户登录授权成功后,TOP颁发给应用的授权信息,详细介绍请点击这里。当此API的标签上注明:“需要授权”,则此参数必传;“不需要授权”,则此参数不需要传;“可选授权”,则此参数为可选
	PartnerId    string // 合作伙伴身份标识
	Timeout      int64  // 请求超时时间
	// contains filtered or unexported fields
}

func New

func New() *Client

func (*Client) Exec

func (c *Client) Exec(req Requester) ([]byte, error)

type Error added in v0.0.4

type Error struct {
	Code      int64  `json:"code"`
	Msg       string `json:"msg"`
	SubCode   string `json:"sub_code"`
	SubMsg    string `json:"sub_msg"`
	RequestID string `json:"request_id"`
}

type ErrorResult

type ErrorResult struct {
	ErrorResponse Error `json:"error_response"`
}

type Parameter

type Parameter map[string]interface{}

type Requester

type Requester interface {
	GetMethod() string
	GetApiParams() Parameter
}

Directories

Path Synopsis
requests
tbk

Jump to

Keyboard shortcuts

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