Giter Site home page Giter Site logo

houseme / bytedance Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 164 KB

Byte Mini Program,Douyin Mini Program bytedance microapp sdk

Home Page: https://houseme.github.io/bytedance/

License: Apache License 2.0

Go 100.00%
bytedance douyin microapp bytedance-microapp douyin-microapp microapp-sdk

bytedance's Introduction

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.

bytedance's People

Contributors

dependabot[bot] avatar houseme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bytedance's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.