前言
本文我们基于飞书开放平台提供的服务端SDK,展示下如何批量发送消息。
代码示例
本文我们基于飞书开平提供的go-sdk进行展示,go-sdk的github地址为:
https://github.com/larksuite/oapi-sdk-go
代码示例如下:
package main
import (
"context"
"fmt"
lark "github.com/larksuite/oapi-sdk-go/v3"
larkcore "github.com/larksuite/oapi-sdk-go/v3/core"
larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1"
"net/http"
"os"
)
type TextMsg struct {
Text string `json:"text,omitempty"`
}
func main() {
// 创建 Client
var appID, appSecret = os.Getenv("APP_ID"), os.Getenv("APP_SECRET")
client := lark.NewClient(appID, appSecret)
// 构建body
body := map[string]interface{}{}
body["msg_type"] = larkim.MsgTypeText
body["content"] = TextMsg{Text: "经老板研究决定,我们过年放假一个月"}
body["open_ids"] = []string{"o