demo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

sdk调用示例

  1. 请先配置下 demo/config.go 的相关参数

  2. 运行测试用例

    # 进入demo文件夹
    cd ./demo
    
    # 测试接收回调事件的相关代码
    go test -v -run=TestCallbackMain
    
    # 测试API调用的相关代码
    go test -v -run=TestApiMain
    

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ShopAppId                  = "xxx"
	ShopAppSecret              = "xxx"
	ShopCallbackToken          = "xxx"
	ShopCallbackEncodingAESKey = "xxx"
)

视频号小店配置,可在「视频号小店 - 服务市场 - 自研」中获得。

View Source
var (
	WindowAppId                  = "xxx"
	WindowAppSecret              = "xxx"
	WindowCallbackToken          = "xxx"
	WindowCallbackEncodingAESKey = "xxx"
)

视频号橱窗配置,可在「视频号助手 - 直播 - 开放能力」中获得

View Source
var (
	RedisAddr     = "localhost:6379"
	RedisPassword = ""
	RedisDB       = 0
)

redis 配置

View Source
var CallbackRepo = new(callbackRepo)

Functions

func ApiMain

func ApiMain()

调用 视频号API 示例

func CallbackMain

func CallbackMain()

接收视频号回调事件示例

Types

type DcsTokenByRedis

type DcsTokenByRedis struct{}

实现 access_token 的 redis 存取方案

func (DcsTokenByRedis) Del

func (DcsTokenByRedis) Del(cacheKey string) error

func (DcsTokenByRedis) Get

func (DcsTokenByRedis) Get(cacheKey string) apis.TokenInfo

func (DcsTokenByRedis) Lock

func (DcsTokenByRedis) Lock(cacheKey string, ttl time.Duration) bool

func (DcsTokenByRedis) Set

func (DcsTokenByRedis) Set(cacheKey string, tokenInfo apis.TokenInfo, ttl time.Duration) error

func (DcsTokenByRedis) Unlock

func (DcsTokenByRedis) Unlock(cacheKey string) error

type Logger

type Logger struct{}

日志记录器,可按需改造

func (Logger) Error

func (Logger) Error(args ...interface{})

func (Logger) Errorf

func (Logger) Errorf(template string, args ...interface{})

func (Logger) Info

func (Logger) Info(args ...interface{})

func (Logger) Infof

func (Logger) Infof(template string, args ...interface{})

Jump to

Keyboard shortcuts

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