bytedance

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

Bytedance Open Platform SDK

Go Report Card Go Reference Bytedance CI License GitHub go.mod Go version (branch)

Bytedance Mini Program Douyin Mini Program bytedance microapp SDK

Installation

Enter your repo. directory and execute following command:

go get -u -v github.com/houseme/bytedance@main
Limitation
golang version >= 1.20
Usage
package main

import (
    "context"
    "fmt"
    
    "github.com/houseme/bytedance"
    "github.com/houseme/bytedance/config"
    "github.com/houseme/bytedance/credential"
    "github.com/houseme/bytedance/utility/cache"
    "github.com/houseme/bytedance/utility/logger"
    "github.com/houseme/bytedance/utility/request"
)

func main() {
    var ctx = context.Background()
    wc := bytedance.New(ctx)
    cfg := config.New(
        ctx,
        config.WithClientKey(""),
        config.WithClientSecret(""),
        config.WithRedirectURL(""),
        config.WithLogger(logger.NewDefaultLogger()),
        config.WithRequest(request.NewDefaultRequest()),
        config.WithCache(cache.NewRedis(ctx, cache.NewDefaultRedisOpts())),
        config.WithScopes(""),
        config.WithSalt(""),
    )
    
    // 获取小程序实例
    miniProgram, err := wc.MiniProgram(ctx, cfg)
    if err != nil {
        panic(err)
    }
    auth := miniProgram.GetAuthorize()
    // 获取用户授权
    var accessToken credential.AccessToken
    if accessToken, err = auth.GetAccessToken(ctx, "code"); err != nil {
        panic(err)
    }
    fmt.Println(accessToken)
    
    // 创建二维码
    qrcode := miniProgram.GetQrcode()
    
    // 获取小程序码
    schema := miniProgram.GetSchema()
    
    // 获取链接
    link := miniProgram.GetLink()

}

License

Bytedance is licensed under the Apache License Version 2.0, 100% free and open-source, forever.

Documentation

Overview

Package bytedance 字节系开放平台

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version added in v0.0.3

func Version() string

Version return version no

Types

type Bytedance

type Bytedance struct {
	// contains filtered or unexported fields
}

Bytedance 字节系开放平台

func New

func New(ctx context.Context) *Bytedance

New 初始化字节系开放平台

func (*Bytedance) MiniProgram added in v0.0.4

func (b *Bytedance) MiniProgram(ctx context.Context, cfg *config.Config) (*miniprogram.MicroApp, error)

MiniProgram mini program

func (*Bytedance) Pay

func (b *Bytedance) Pay(ctx context.Context, cfg *config.Config) (*payment.Pay, error)

Pay create payment

func (*Bytedance) SetCache

func (b *Bytedance) SetCache(cache cache.Cache)

SetCache 设置缓存

func (*Bytedance) SetLogger

func (b *Bytedance) SetLogger(logger logger.ILogger)

SetLogger 设置日志

func (*Bytedance) SetRequest

func (b *Bytedance) SetRequest(request request.Request)

SetRequest 设置请求

Directories

Path Synopsis
Package config Configuration information of the DouYin Open Platform
Package config Configuration information of the DouYin Open Platform
Package credential mini program credentials
Package credential mini program credentials
Package miniprogram mini program
Package miniprogram mini program
authorize
Package authorize mini program authorize
Package authorize mini program authorize
link
Package link generate short links
Package link generate short links
schema
Package schema Schema link
Package schema Schema link
Package payment payment
Package payment payment
Package utility universal tool package
Package utility universal tool package
base
Package base universal tool package
Package base universal tool package
cache
Package cache universal tool package
Package cache universal tool package
helper
Package helper universal tool package
Package helper universal tool package
logger
Package logger universal tool package
Package logger universal tool package
request
Package request http request
Package request http request

Jump to

Keyboard shortcuts

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