Skip to content

Latest commit

 

History

History
177 lines (136 loc) · 3.42 KB

README_CN.md

File metadata and controls

177 lines (136 loc) · 3.42 KB

English | 简体中文

Easy Cross Border (EasyCb-Go)

Lazada/TikTok/Shopee卖家开放平台Golang SDK

MIT license Go.Dev reference

概述

EasyCb 未来将支持以下平台:

  • Shopify
  • Amazon
  • AliExpress
  • ...

开始使用

准备工作

EasyCb 需要 Go 版本>= 1.17 及更高版本

import "github.com/easycb/easycb-go"

或者使用 go get:

go get -u github.com/easycb/easycb-go

运行 EasyCb

Lazada 基础使用示例:

package main

import (
	"fmt"
	"time"
	"github.com/easycb/easycb-go"
	"github.com/easycb/easycb-go/lazada"
)

func main() {
	appKey := ""
	appSecret := ""
	baseUrl := "https://api.lazada.com.my/rest"
	accessToken := ""
	client, err := lazada.NewClient(appKey, appSecret, baseUrl)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	client.SetAccessToken(accessToken)

	query := easycb.AnyMap{
		"sort_direction": "DESC",
		"offset":         0,
		"limit":          100,
		"sort_by":        "created_at",
		"created_before": time.Now().Format(time.RFC3339),
		"created_after":  time.Now().Add(-15 * 24 * time.Hour).Format(time.RFC3339),
	}

	res, err := client.GetOrders(query)
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	fmt.Println(res.Code)
}

Shopee 基础使用示例:

package main

import (
	"fmt"
	"time"
	"github.com/easycb/easycb-go"
	"github.com/easycb/easycb-go/shopee"
)

func main() {
	partnerId := int64(123456)
	partnerKey := ""
	baseUrl := "https://partner.shopeemobile.com"
	shopId := int64(56789)
	accessToken := ""
	client, err := shopee.NewClient(partnerId, partnerKey, baseUrl)
	if err != nil {
		return
	}
	client.SetShopId(shopId).SetAccessToken(accessToken)
	
	
	query := easycb.AnyMap{
		"offset":      0,
		"page_size":   50,
		"item_status": []string{"NORMAL", "UNLIST"},
	}

	res, err := client.GetProductList(query)
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	fmt.Println(res.Message)
}

Tiktok 基础使用示例:

package main

import (
	"fmt"
	"time"
	"github.com/easycb/easycb-go"
	"github.com/easycb/easycb-go/tiktok"
)

func main() {
	appKey := ""
	appSecret := ""
	baseUrl := "https://open-api.tiktokglobalshop.com"
	accessToken := ""
	shopCipher := ""
	client, err := tiktok.NewClient(appKey, appSecret, baseUrl)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	client.SetAccessToken(accessToken).SetShopCipher(shopCipher)

	query := easycb.AnyMap{
		"page_size": 20,
	}

	body := easycb.AnyMap{
		"create_time_ge": time.Now().Add(-15 * 24 * time.Hour).Unix(),
		"create_time_lt": time.Now().Unix(),
	}
	
	res, err := client.GetOrderList(query, body)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	
	fmt.Println(res.Code)
}

贡献者

感谢 对EasyCb贡献!

许可

协议 MIT License