bytedance

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 9 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 {
	Version string
	// contains filtered or unexported fields
}

Bytedance 字节系开放平台

func New

func New(ctx context.Context) *Bytedance

New 初始化字节系开放平台

func (*Bytedance) MiniDrama added in v0.0.9

func (b *Bytedance) MiniDrama(ctx context.Context, cfg *config.Config) (*minidrama.MiniDrama, error)

MiniDrama create drama

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) (*pay.Pay, error)

Pay create payment

func (*Bytedance) Payment added in v0.0.9

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

Payment 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 minidrama mini drama
Package minidrama mini drama
drama
Package drama drama
Package drama drama
voc
Package voc voc
Package voc voc
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
pay
Package pay 支付
Package pay 支付
refund
Package refund 退款
Package refund 退款
trade
Package trade 交易
Package trade 交易
Package payment payment
Package payment payment
bill
Package bill query merchant bill
Package bill query merchant bill
constant
Package constant payment constant
Package constant payment constant
syncorder
Package syncorder order sync to douyin
Package syncorder order sync to douyin
trade
Package trade 交易
Package trade 交易
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