taoke

package module
v1.1.0 Latest Latest
Warning

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

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

README

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

淘宝API

sign算法

淘宝Session

Example-Taobao

package main

import (
	"fmt"
	"github.com/dshechao/go-taoke"
)

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

func main() {
	res, err := taoke.Execute("taobao.tbk.dg.material.optional", taoke.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"])
	}
}

Example - JingDong

package main

import (
	"github.com/dshechao/go-taoke"
	"log"
)

func init() {
	taoke.AppKey = ""
	taoke.AppSecret = ""
        taoke.Router ="https://router.jd.com/api"
	taoke.V = "1.0"
	taoke.Platform = "2"
}

func main() {

	result, err := taoke.Execute("jd.union.open.goods.jingfen.query1", taoke.Parameter{
		"goodsReq":taoke.Parameter{"eliteId":    "1"},
	})

	if err != nil {
		log.Printf("execute error:%s\n", err)
		return
	}
	data, _ := result.MarshalJSON()
	log.Printf("result:%s\n", data)
}


Example - 多多进宝

package main

import (
	"github.com/dshechao/go-taoke"
	"log"
)

func init() {
	taoke.AppKey = "client_id"
	taoke.AppSecret = "client_secret"
	taoke.Router = "https://gw-api.pinduoduo.com/api/router"
	taoke.Platform = "3"
        taoke.V = "1.0"
}

func main() {

	result, err := taoke.Execute("pdd.ddk.goods.search", taoke.Parameter{
    		"keyword":"华为手机",
    	})

	if err != nil {
		log.Printf("execute error:%s\n", err)
		return
	}
	data, _ := result.MarshalJSON()
	log.Printf("result:%s\n", data)
}


Example - 考拉赚客

package main

import (
	"github.com/dshechao/go-taoke"
	"log"
)

func init() {
    taoke.AppKey = "赚客ID"
    taoke.AppSecret = "AppSecret"
    taoke.Router = "https://cps.kaola.com/zhuanke/api"
    taoke.Platform = "4"
    taoke.V = "1.0"
}

func main() {

	result, err := taoke.Execute("kaola.zhuanke.api.queryRecommendGoodsList", taoke.Parameter{
    		"sortType":1,
    		"pageIndex":1,
    	})

	if err != nil {
		log.Printf("execute error:%s\n", err)
		return
	}
	data, _ := result.MarshalJSON()
	log.Printf("result:%s\n", data)
}


Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	/**淘宝平台信息**/
	// AppKey 应用Key
	AppKeyTaobao string
	// AppSecret 秘密
	AppSecretTaobao string
	// Router 环境请求地址
	RouterTaobao string
	//API Version ...
	VersionTaobao = "2.0"
	// Session 用户登录授权成功后,TOP颁发给应用的授权信息。当此API的标签上注明:“需要授权”,则此参数必传;“不需要授权”,则此参数不需要传;“可选授权”,则此参数为可选
	Session string
	// Timeout ...
	Timeout time.Duration
	// CacheExpiration 缓存过期时间
	CacheExpiration = time.Hour
	// GetCache 获取缓存
	GetCache cache.GetCacheFunc
	// SetCache 设置缓存
	SetCache cache.SetCacheFunc

	/**京东平台信息**/
	// AppKey 应用Key
	AppKeyJingDong string
	// AppSecret 秘密
	AppSecretJingDong string
	// Router 环境请求地址
	RouterJingDong string
	//API Version ...
	VersionJingDong = "1.0"

	/**拼多多平台信息**/
	// AppKey 应用Key
	ClientIdPDD string
	// AppSecret 秘密
	ClientSecretPDD string
	// Router 环境请求地址
	RouterPDD string
	//API Version ...
	VersionPDD = "1.0"

	/**考拉海购平台信息**/
	// AppKey 应用Key
	UnionIdKL string
	// AppSecret 秘密
	SecretKL string
	// Router 环境请求地址
	RouterKL string
	//API Version ...
	VersionKL = "1.0"
)
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