jums

package module
v0.0.0-...-4fe0a63 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 4 Imported by: 0

README

go-jums

概述

jums为极光ums推送的go语言api封装,http请求使用fiber web 框架的内置方法,适用于fiber web 框架使用

官方 REST API 文档: https://docs.jiguang.cn/jums/guideline/intro

安装

使用 go get 安装,无任何第三方依赖:

go get github.com/duxphp/go-jums

使用方法

1. 创建 Jums

import "github.com/duxphp/go-jums"

client := jums.New(jums.Config{
	Key: ""
	Secret: ""
})

2. 消息发送 (目前不支持模板消息)

可自行调用 jums.Toxx 方法进行使用

client.Message().To(jums.ToSms("sms", []string{"18000000000"})).Content(jums.MsgSms("1", 1, map[string]any{"code": "1234"})).Send()
3. 用户管理

可自行调用 jums.UserXXX 方法进行使用

client.User().SetId(123).Add(UserTag("channelKey", "标签一", "标签二")).Send()
4 用户删除
client.User().SetId(123).UserDel(1,,2,,3)

Documentation

Index

Constants

View Source
const (
	WechatWkText  wechatWkType = "text"
	WechatWkImage wechatWkType = "image"
	WechatWkFile  wechatWkType = "file"
	WechatWkNews  wechatWkType = "news"
	WechatWkMpews wechatWkType = "mpnews"
)
View Source
const (
	BaseAPI = "https://api.ums.jiguang.cn/"
)

Variables

This section is empty.

Functions

func Request

func Request(url string, key string, secret string, data any) error

Request 请求数据

func UserAlipayLife

func UserAlipayLife(instance string, data string) *userType

UserAlipayLife 支付宝生活号

func UserApp

func UserApp(instance string, data ...string) *userType

UserApp app类型

func UserDingtalkCC

func UserDingtalkCC(data string) *userType

UserDingtalkCC 钉钉

func UserEmail

func UserEmail(channelKey string, data ...string) *userType

UserEmail 渠道邮箱

func UserPhone

func UserPhone(channelKey string, data ...string) *userType

UserPhone 渠道手机号

func UserTag

func UserTag(channelKey string, data ...string) *userType

UserTag 渠道标签

func UserWechatMp

func UserWechatMp(instance string, data string) *userType

UserWechatMp 微信小程序

func UserWechatOa

func UserWechatOa(instance string, data string) *userType

UserWechatOa 微信公众号

func UserWechatWk

func UserWechatWk(data string) *userType

UserWechatWk 企业微星

Types

type AlipayData

type AlipayData struct {
	Value string `json:"value"`
	Color string `json:"color"`
}

type Config

type Config struct {
	Key           string
	Secret        string
	AccountKey    string
	AccountSecret string
}

type Jums

type Jums struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) *Jums

New 极光统一推送

func (*Jums) Message

func (u *Jums) Message() *Message

Message 消息模式

func (*Jums) User

func (u *Jums) User() *Users

User 用户模式

func (*Jums) UserDel

func (u *Jums) UserDel(userid ...uint) error

UserDel 批量删除用户

type Message

type Message struct {
	Key    string
	Secret string
	Data   map[string]any
}

Message 普通消息推送

func (*Message) Content

func (u *Message) Content(datas ...*MsgData) *Message

Content 发送消息内容

func (*Message) Send

func (u *Message) Send() error

Send 发送消息内容

func (*Message) To

func (u *Message) To(datas ...*ToData) *Message

To 发送消息对象

type MsgData

type MsgData map[string]any

func MsgAlipayLife

func MsgAlipayLife(tempId int, headColor string, url string, desc string, data map[string]AlipayData) *MsgData

MsgAlipayLife 阿里生活号

func MsgApp

func MsgApp(msg string, url string) *MsgData

MsgApp app消息

func MsgDingtalkCC

func MsgDingtalkCC(content string) *MsgData

MsgDingtalkCC 钉钉通知

func MsgEmail

func MsgEmail(title string, content string, files ...[]string) *MsgData

MsgEmail 邮件消息

func MsgSms

func MsgSms(signId string, tempId int, params map[string]any) *MsgData

MsgSms 短信消息

func MsgWechatmp

func MsgWechatmp(tplId string, data map[string]WechatmpData, pages ...string) *MsgData

MsgWechatmp 小程序消息

func MsgWechatoa

func MsgWechatoa(types uint, tplId string, data map[string]WechatoaData, url string, minis ...WechatMiniprogram) *MsgData

MsgWechatoa 公众号消息

func MsgWechatwk

func MsgWechatwk(config any) *MsgData

MsgWechatwk 企业微信

type ToData

type ToData map[string]any

func ToAlipayLife

func ToAlipayLife(instance string, aud []string) *ToData

ToAlipayLife 支付宝生活号

func ToApp

func ToApp(instance string, aud []string) *ToData

ToApp App

func ToDingtalkCC

func ToDingtalkCC(instance string, aud []string) *ToData

ToDingtalkCC 钉钉工作

func ToEmail

func ToEmail(instance string, aud []string) *ToData

ToEmail 邮件

func ToSegment

func ToSegment(aud []string) *ToData

ToSegment 用户群

func ToSms

func ToSms(instance string, aud []string) *ToData

ToSms 短信

func ToTag

func ToTag(aud []string) *ToData

ToTag 用户标签

func ToUser

func ToUser(aud []string) *ToData

ToUser 用户id

func ToWechatmp

func ToWechatmp(instance string, aud []string) *ToData

ToWechatmp 微信小程序

func ToWechatoa

func ToWechatoa(instance string, aud []string) *ToData

ToWechatoa 微信公众号

func ToWechatwk

func ToWechatwk(instance string, aud []string) *ToData

ToWechatwk 企业微信

type Users

type Users struct {
	Key           string
	Secret        string
	AccountKey    string
	AccountSecret string
	Data          map[string]any
	UserId        uint
}

func (*Users) Add

func (u *Users) Add(types ...*userType) *Users

Add 添加数据

func (*Users) Del

func (u *Users) Del(types ...*userType) *Users

Del 删除数据

func (*Users) Send

func (u *Users) Send() error

Send 发送消息内容

func (*Users) Set

func (u *Users) Set(types ...*userType) *Users

Set 设置数据

func (*Users) SetId

func (u *Users) SetId(userId uint) *Users

SetId 设置用户id

type WechatMiniprogram

type WechatMiniprogram struct {
	AppId    string `json:"app_id"`
	PagePath string `json:"page_path"`
}

type WechatWkConfigFile

type WechatWkConfigFile struct {
	MediaId string `json:"media_id"`
}

type WechatWkConfigImage

type WechatWkConfigImage struct {
	MediaId string `json:"media_id"`
}

type WechatWkConfigMpnews

type WechatWkConfigMpnews struct {
	Title            string `json:"title"`
	Content          string `json:"content"`
	Digest           string `json:"digest"`
	Author           string `json:"author"`
	ContentSourceUrl string `json:"content_source_url"`
	// contains filtered or unexported fields
}

type WechatWkConfigNews

type WechatWkConfigNews struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Url         string `json:"url"`
	Picurl      string `json:"picurl"`
}

type WechatWkConfigText

type WechatWkConfigText struct {
	Content string `json:"content"`
}

type WechatmpData

type WechatmpData struct {
	Value string `json:"value"`
}

type WechatoaData

type WechatoaData struct {
	Value string `json:"value"`
	Color string `json:"color"`
}

Jump to

Keyboard shortcuts

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