feishu

package module
v1.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: Apache-2.0 Imports: 12 Imported by: 2

README

fastwego/feishu

A fast feishu development sdk written in Golang

GoDoc Go Report Card

快速开始 & demo

go get github.com/fastwego/feishu
// 内部应用 tenant_access_token 管理器
Atm = &feishu.DefaultAccessTokenManager{
    Id:    FeishuConfig["AppId"],
    Cache: file.New(os.TempDir()),
    GetRefreshRequestFunc: func() *http.Request {
        payload := `{
            "app_id":"` + FeishuConfig["AppId"] + `",
            "app_secret":"` + FeishuConfig["AppSecret"] + `"
        }`
        req, _ := http.NewRequest(http.MethodPost, feishu.ServerUrl+"/open-apis/auth/v3/tenant_access_token/internal/", strings.NewReader(payload))
        return req
    },
}

// 创建 飞书 客户端
FeishuClient = feishu.NewClient()

// 调用 api 接口
tenantAccessToken, _ := Atm.GetAccessToken()

params := url.Values{}
params.Add("page_size", "10")
request, _ := http.NewRequest(http.MethodGet, feishu.ServerUrl+"/open-apis/meeting_room/building/list?"+params.Encode(), nil)
resp, err := FeishuClient.Do(request, tenantAccessToken)

完整演示项目:

https://github.com/fastwego/feishu-demo

架构设计

sdk

框架特点

  • 使用 Go 语言,开发快、编译快、部署快、运行快,轻松服务海量用户
  • 丰富的文档演示代码 ,快速上手,5 分钟即可搭建一个完整地飞书 App
  • 独立清晰的模块划分,快速熟悉整个框架,没有意外,一切都是你期望的样子
  • 直接调用接口,最少封装,自由嵌入业务逻辑
  • 简单而强大的 AccessToken 管理:
    • 默认将 AccessToken 缓存到本机临时目录下
    • 过期自动重新获取
    • 支持自定义 AccessToken 的获取和管理方法,扩展应用场景
    • 支持企业内部应用/应用商店应用不同类型的 AccessToken 管理
  • 事件回调加解密处理
  • 丰富完整&支持自定义的日志
  • 支持自定义 http.Client:
    • 默认使用 http.DefaultClient

活跃的开发者社区

FastWeGo 是一套丰富的 Go 服务开发框架,支持飞书、微信等服务,拥有庞大的开发者用户群体

你遇到的所有问题几乎都可以在社区找到解决方案

欢迎提交 pull request / issue / 文档,一起让飞书开发更快更好!

Faster we go together!

加入开发者交流群

Documentation

Overview

飞书开发 SDK

Index

Constants

This section is empty.

Variables

View Source
var (
	ServerUrl  = "https://open.feishu.cn"
	ServerUrl2 = "https://www.feishu.cn"
	UserAgent  = "fastwego/feishu"
)
View Source
var Logger = log.New(os.Stdout, "[fastwego/feishu] ", log.LstdFlags|log.Llongfile)

日志记录器

Functions

This section is empty.

Types

type AccessTokenManager

type AccessTokenManager interface {
	GetAccessToken() (accessToken string, err error)
}

type Client

type Client struct {
	HttpClient *http.Client
}

Client 用于向接口发送请求

func NewClient

func NewClient() (client *Client)

NewClient

func (*Client) Do

func (client *Client) Do(req *http.Request, accessToken string) (resp []byte, err error)

Do 执行 请求

type Crypto

type Crypto struct {
	EncryptKey        string
	VerificationToken string
}

func NewCrypto

func NewCrypto(EncryptKey string) *Crypto

NewCrypto 创建加解密处理器

func (*Crypto) GetDecryptMsg

func (c *Crypto) GetDecryptMsg(encryptMsg string) (decryptMsg []byte, err error)

GetDecryptMsg 解密消息

type DefaultAccessTokenManager

type DefaultAccessTokenManager struct {
	Id                    string
	GetRefreshRequestFunc getRefreshRequestFunc
	Cache                 cachego.Cache
}

func (*DefaultAccessTokenManager) GetAccessToken

func (m *DefaultAccessTokenManager) GetAccessToken() (accessToken string, err error)

GetAccessToken

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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