wecom

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 9 Imported by: 0

README

wecom-push

企业微信推送 golang sdk

自动管理 access_token
线程安全

Example

package main

import (
	"os"

	"github.com/jzksnsjswkw/wecom-push"
)

func main() {
	corpid := "xxxxx"
	corpsecret := "xxxxxx"
	w := wecom.New(corpid, corpsecret)

	err := w.Text(&wecom.TextInfo{
		Touser:  "Pony",
		AgentID: 1000002,
		Content: "test",
	})
	if err != nil {
		panic(err)
	}

	b, err := os.ReadFile("./test.txt")
	if err != nil {
		panic(err)
	}
	err = w.File(&wecom.FileInfo{
		Touser:   "Pony",
		AgentID:  1000002,
		Content:  b,
		Filetype: wecom.FILE,
		Filename: "test.txt",
	})
	if err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(corpid, corpsecret string) *wecom

Types

type FileInfo added in v1.0.1

type FileInfo struct {
	Touser   string
	AgentID  int
	Content  []byte
	Filetype Filetype
	Filename string

	// 仅VIDEO有效
	Title string
	// 仅VIDEO有效
	Description string
}

type Filetype

type Filetype string
const (
	IMAGE Filetype = "image"
	VOICE Filetype = "voice"
	VIDEO Filetype = "video"
	FILE  Filetype = "file"
)

type TextInfo

type TextInfo struct {
	Touser  string
	AgentID int
	Content string
}

Jump to

Keyboard shortcuts

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