package feishu import ( "bytes" "encoding/json" "fusenapi/utils/curl" "time" ) type FeiShuApi struct { AppId string AppSecret string ApiHost string } // 获取tenant_access_token type GetTenantAccessTokenRsp struct { Code int `json:"code"` Msg string `json:"msg"` TenantAccessToken string `json:"tenant_access_token"` Expire int `json:"expire"` } func (f *FeiShuApi) GetTenantAccessToken() (resp GetTenantAccessTokenRsp, err error) { url := f.ApiHost + "/open-apis/auth/v3/tenant_access_token/internal" header := map[string]string{"Content-Type": "application/json; charset=utf-8"} req := map[string]interface{}{ "app_secret": f.AppSecret, "app_id": f.AppId, } postData, _ := json.Marshal(req) rsp, err := curl.ApiCall2(url, "POST", header, bytes.NewReader(postData), time.Second*15) if err != nil { return GetTenantAccessTokenRsp{}, err } if err = json.Unmarshal(rsp, &resp); err != nil { return GetTenantAccessTokenRsp{}, err } return resp, nil }