Documentation
¶
Index ¶
- Constants
- Variables
- func Bool2Int(b bool) int
- func Byte2String(b []byte) string
- func D(data interface{})
- func FirstDateOfYear() time.Time
- func Float642String(v float64, p int) string
- func Int2String(val int) string
- func Int642String(val int64) string
- func Paginator(page int, count int, list interface{}) map[string]interface{}
- func R(data interface{}, name string)
- func RandNum(l int) string
- func RandStr(l int) string
- func RandomNum(min, max int) int
- func String2Float64(str string) (float64, error)
- func String2Int(str string) (int, error)
- func String2Int64(str string) (int64, error)
- func String2Time(paramTime string) (returnTime time.Time)
- func String2Uint(str string) uint
- func String2Unix(paramTime string) int64
- func Time2String(t time.Time) string
- func Time2Unix(paramTime time.Time) int64
- func TodayDate() (tm time.Time)
- func Uint642String(val uint64) string
- func Unix2String(stamp int64) string
- func Unix2Time(stamp int64) time.Time
- type AuthReq
- type AuthResp
- type Authorizer
- type Client
- func (client *Client) Auth() error
- func (client *Client) ChangeDefaultChannel(channel, webhook string) (detail Resp, err error)
- func (client *Client) ChangeIsSend(isSend int) (detail IntResp, err error)
- func (client *Client) ChangeOpenMessageType(msgType int) (detail IntResp, err error)
- func (client *Client) ChangeReceiveLimit(limit int) (detail Resp, err error)
- func (client *Client) CpList(page, pageSize int) (list CpListResp, err error)
- func (client *Client) DeleteTopicUser(id int) (result Resp, err error)
- func (client *Client) ExistTopic(topicID int) (detail Resp, err error)
- func (client *Client) FriendDel(id int) (detail IntResp, err error)
- func (client *Client) FriendEditRemark(id int, remark string) (detail IntResp, err error)
- func (client *Client) FriendGetQRCode() (detail FriendQRCode, err error)
- func (client *Client) FriendList(page, pageSize int) (list FriendListResp, err error)
- func (client *Client) GetTopicQrCode(topicID, forever int) (detail QrCodeResp, err error)
- func (client *Client) GetUserInfo() (result UserInfo, err error)
- func (client *Client) GetUserLimitTime() (result UserLimitTimeResp, err error)
- func (client *Client) GetUserSettings() (detail UserSetting, err error)
- func (client *Client) GetUserToken() (result Resp, err error)
- func (client *Client) MailDetail(mailID int) (detail MailDetailResp, err error)
- func (client *Client) MailList(page, pageSize int) (list MailListResp, err error)
- func (client *Client) MessageList(page, pageSize int) (list MsgListResp, err error)
- func (client *Client) MpList(page, pageSize int) (list MpListResp, err error)
- func (client *Client) SendMessageResult(shortCode string) (result SendMsgResultResp, err error)
- func (client *Client) SendMsg(title, content string) (result Resp, err error)
- func (client *Client) TopicAdd(req TopicAddReq) (result TopicAddResp, err error)
- func (client *Client) TopicDetail(topicID int) (detail TopicDetailResp, err error)
- func (client *Client) TopicJoinDetail(topicID int) (detail TopicJoinDetailResp, err error)
- func (client *Client) TopicList(page, pageSize, topicType int) (list TopicListResp, err error)
- func (client *Client) TopicUserList(page, pageSize, topicID int) (list TopicUserListResp, err error)
- func (client *Client) UserSendCount() (result UserLimitTimeResp, err error)
- func (client *Client) WebhookAdd(req WebhookReq) (result TopicAddResp, err error)
- func (client *Client) WebhookDetail(id int) (detail WebhookResp, err error)
- func (client *Client) WebhookEdit(req WebhookData) (result Resp, err error)
- func (client *Client) WebhookList(page, pageSize int) (list WebhookListResp, err error)
- type CpData
- type CpListResp
- type DefaultAuthorizer
- type EditFriendReq
- type FriendData
- type FriendListResp
- type FriendQRCode
- type IntResp
- type MailData
- type MailDetailResp
- type MailListResp
- type MpData
- type MpListResp
- type MsgListResp
- type Option
- type PageReq
- type Pager
- type QrCodeResp
- type Resp
- type SendMsgCallbackResp
- type SendMsgReq
- type SendMsgResultResp
- type TopicAddReq
- type TopicAddResp
- type TopicDetailResp
- type TopicJoinDetailResp
- type TopicListReq
- type TopicListResp
- type TopicUserListReq
- type TopicUserListResp
- type UserInfo
- type UserLimitTimeResp
- type UserSendCountResp
- type UserSetting
- type WebhookData
- type WebhookListResp
- type WebhookReq
- type WebhookResp
Constants ¶
const ( SendMsgURL = "/send" GetAccessKeyURL = "/api/common/openApi/getAccessKey" MsgListURL = "/api/open/message/list" MsgResultURL = "/api/open/message/sendMessageResult?shortCode=" UserTokenURL = "/api/open/user/token" UserInfoURL = "/api/open/user/myInfo" UserLimitTimeURL = "/api/open/user/userLimitTime" UserSendCount = "/api/open/user/sendCount" TopicAddURL = "/api/open/topic/add" TopicListURL = "/api/open/topic/list" ExitTopicURL = "/api/open/topic/exitTopic?topicId=" TopicDetailURL = "/api/open/topic/detail?topicId=" JoinTopicDetailURL = "/api/open/topic/joinTopicDetail?topicId=" TopicQRCode = "/api/open/topic/qrCode?topicId=" // 二维码类型;0-临时二维码,1-永久二维码 SubscriberListURL = "/api/open/topicUser/subscriberList" DeleteTopicUserURL = "/api/open/topicUser/deleteTopicUser?topicRelationId=" WebhookListURL = "/api/open/webhook/list" WebhookDetailURL = "/api/open/webhook/detail?webhookId=" WebhookAddURL = "/api/open/webhook/add" WebhookEditURL = "/api/open/webhook/edit" WebhookMpList = "/api/open/mp/list" WebhookCpList = "/api/open/cp/list" WebhookMailList = "/api/open/mail/list" WebhookMailDetail = "/api/open/mail/detail?mailId=" GetUserSettingsURL = "/api/open/setting/getUserSettings" ChangeDefaultChannelURL = "/api/open/setting/changeDefaultChannel" ChangeReceiveLimitURL = "/api/open/setting/changeRecevieLimit?recevieLimit=" ChangeIsSend = "/api/open/setting/changeIsSend?isSend=" FriendGetQrCode = "/api/open/friend/getQrCode" FriendList = "/api/open/friend/list" DeleteFriend = "/api/open/friend/deleteFriend?friendId=" FriendEditRemark = "/api/open/friend/editRemark" )
const DateFormat = "2006-01-02"
const TimeFormat = "2006-01-02 15:04:05"
Variables ¶
var ( UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36" BaseURL = "https://www.pushplus.plus" )
Functions ¶
func FirstDateOfYear ¶
FirstDateOfYear 今年第一天 eg:2021-01-01 00:00:00
func String2Float64 ¶
String2Float64 string 转 float64
func String2Time ¶
String2Time 字符串格式[转换为]time,Time(时间对象) eg:(2019-09-09T09:09:09+08:00)
func String2Unix ¶
String2Unix 字符串格式[转换为]时间戳 eg:(1557398617)
func Time2String ¶
Time2String 时间对象[转换为]字符串 eg:(2019-09-09 09:09:09)
func Uint642String ¶
func Unix2String ¶
Unix2String 时间戳[转换为]字符串 eg:(2019-09-09 09:09:09)
Types ¶
type Authorizer ¶
type Client ¶
type Client struct {
Req *req.Client
AccessKey string
Authorizer Authorizer
Token string
SecretKey string
Topic string
Template string
Channel string
Webhook string
Callback string
To string
DebugLog bool
// contains filtered or unexported fields
}
func (*Client) ChangeDefaultChannel ¶
ChangeDefaultChannel 修改默认发送渠道 channel 默认渠道;wechat-微信公众号,mail-邮件,cp-企业微信应用,webhook-第三方webhook webhook 渠道参数;webhook和cp渠道需要填写具体的webhook编号或自定义编码
func (*Client) ChangeIsSend ¶
ChangeIsSend 开启/关闭发送消息功能 isSend 发送消息功能;0-禁用,1-启用
func (*Client) ChangeOpenMessageType ¶
ChangeOpenMessageType 修改打开消息方式 msgType 消息打开类型;0:H5,1:小程序
func (*Client) ChangeReceiveLimit ¶
ChangeReceiveLimit 修改接收消息限制 limit 接收消息限制;0-接收全部,1-不接收消息
func (*Client) CpList ¶
func (client *Client) CpList(page, pageSize int) (list CpListResp, err error)
CpList 获取企业微信渠道列表 page 当前所在分页数, pageSize 每页大小最大值为50
func (*Client) DeleteTopicUser ¶
DeleteTopicUser 删除群组内用户 id 用户编号
func (*Client) ExistTopic ¶
ExistTopic 退出群组 topicID 群组 ID
func (*Client) FriendEditRemark ¶
FriendEditRemark 修改好友备注 id 好友编号, remark 好友备注
func (*Client) FriendGetQRCode ¶
func (client *Client) FriendGetQRCode() (detail FriendQRCode, err error)
FriendGetQRCode 获取个人二维码
func (*Client) FriendList ¶
func (client *Client) FriendList(page, pageSize int) (list FriendListResp, err error)
FriendList 获取好友列表 page 当前所在分页数, pageSize 每页大小最大值为50
func (*Client) GetTopicQrCode ¶
func (client *Client) GetTopicQrCode(topicID, forever int) (detail QrCodeResp, err error)
GetTopicQrCode 获取群组二维码 topicID 群组 ID forever 二维码类型;0-临时二维码,1-永久二维码
func (*Client) GetUserInfo ¶
func (*Client) GetUserLimitTime ¶
func (client *Client) GetUserLimitTime() (result UserLimitTimeResp, err error)
func (*Client) GetUserSettings ¶
func (client *Client) GetUserSettings() (detail UserSetting, err error)
func (*Client) GetUserToken ¶
func (*Client) MailDetail ¶
func (client *Client) MailDetail(mailID int) (detail MailDetailResp, err error)
MailDetail 获取邮箱渠道详情 mailID 邮箱编号
func (*Client) MailList ¶
func (client *Client) MailList(page, pageSize int) (list MailListResp, err error)
MailList 获取邮箱渠道列表 page 当前所在分页数, pageSize 每页大小最大值为50
func (*Client) MessageList ¶
func (client *Client) MessageList(page, pageSize int) (list MsgListResp, err error)
MessageList 消息列表 page 当前所在分页数, pageSize 每页大小最大值为50
func (*Client) MpList ¶
func (client *Client) MpList(page, pageSize int) (list MpListResp, err error)
MpList 获取微信公众号渠道列表 page 当前所在分页数, pageSize 每页大小最大值为50
func (*Client) SendMessageResult ¶
func (client *Client) SendMessageResult(shortCode string) (result SendMsgResultResp, err error)
SendMessageResult 查询消息发送结果 shortCode 消息短链码
func (*Client) TopicAdd ¶
func (client *Client) TopicAdd(req TopicAddReq) (result TopicAddResp, err error)
TopicAdd 新增群组
func (*Client) TopicDetail ¶
func (client *Client) TopicDetail(topicID int) (detail TopicDetailResp, err error)
TopicDetail 获取我创建的群组详情 topicID 群组 ID
func (*Client) TopicJoinDetail ¶
func (client *Client) TopicJoinDetail(topicID int) (detail TopicJoinDetailResp, err error)
TopicJoinDetail 获取我加入的群详情 topicID 群组 ID
func (*Client) TopicList ¶
func (client *Client) TopicList(page, pageSize, topicType int) (list TopicListResp, err error)
TopicList 群组列表 page 当前所在分页数, pageSize 每页大小最大值为50, topicType 群组类型: 0-我创建的,1-我加入的
func (*Client) TopicUserList ¶
func (client *Client) TopicUserList(page, pageSize, topicID int) (list TopicUserListResp, err error)
TopicUserList 群组内用户列表 page 当前所在分页数, pageSize 每页大小最大值为50, topicType 群组类型: 0-我创建的,1-我加入的
func (*Client) UserSendCount ¶
func (client *Client) UserSendCount() (result UserLimitTimeResp, err error)
func (*Client) WebhookAdd ¶
func (client *Client) WebhookAdd(req WebhookReq) (result TopicAddResp, err error)
WebhookAdd 新增Webhook
func (*Client) WebhookDetail ¶
func (client *Client) WebhookDetail(id int) (detail WebhookResp, err error)
WebhookDetail 获取我加入的群详情 topicID 群组 ID
func (*Client) WebhookEdit ¶
func (client *Client) WebhookEdit(req WebhookData) (result Resp, err error)
WebhookEdit 编辑Webhook
func (*Client) WebhookList ¶
func (client *Client) WebhookList(page, pageSize int) (list WebhookListResp, err error)
WebhookList Webhook列表 page 当前所在分页数, pageSize 每页大小最大值为50
type CpListResp ¶
type DefaultAuthorizer ¶
type DefaultAuthorizer struct{}
func (DefaultAuthorizer) Authorize ¶
func (da DefaultAuthorizer) Authorize(client *Client) (err error)
type EditFriendReq ¶
type FriendData ¶
type FriendData struct {
Id int `json:"id"` // 好友编号
FriendId int `json:"friendId"` // 好友id
Token string `json:"token"` // 好友令牌;发送好友消息使用
HeadImgUrl string `json:"headImgUrl"` // 好友头像
NickName string `json:"nickName"` // 好友昵称
EmailStatus int `json:"emailStatus"` // 邮箱验证状态;0-未验证,1-待验证,2-已验证
HavePhone int `json:"havePhone"` // 是否绑定手机;0-未绑定,1-已绑定
IsFollow int `json:"isFollow"` // 是否关注微信公众号;0-未关注,1-已关注
Remark string `json:"remark"` // 备注
CreateTime string `json:"createTime"` // 创建日期
}
type FriendListResp ¶
type FriendListResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
Pager
List []FriendData `json:"list"`
} `json:"data"`
}
type FriendQRCode ¶
type MailData ¶
type MailData struct {
Id int `json:"id"` // 邮箱编号
MailName string `json:"mailName"` // 邮箱名称
MailCode string `json:"mailCode"` // 邮箱编码
Account string `json:"account,omitempty"`
Password string `json:"password,omitempty"`
SmtpServer string `json:"smtpServer,omitempty"`
SmtpSsl int `json:"smtpSsl,omitempty"`
SmtpPort int `json:"smtpPort,omitempty"`
CreateTime string `json:"createTime,omitempty"`
}
type MailDetailResp ¶
type MailListResp ¶
type MpData ¶
type MpData struct {
Id int `json:"id"` // 微信公众号编号
NickName string `json:"nickName"` // 微信公众号名称
HeadImg string `json:"headImg"` // 微信公众号头像
PrincipalName string `json:"principalName"` // 公众号的主体名称
AuthorizationAppid string `json:"authorizationAppid"` // 授权方appid
FuncInfo string `json:"funcInfo"` // 权限集列表
ServiceType int `json:"serviceType"` // 授权方公众号类型,0 代表订阅号,1 代表由历史老账号升级后的订阅号,2 代表服务号
VerifyType int `json:"verifyType"` // 授权方认证类型,-1 代表未认证,0 代表微信认证
Alias string `json:"alias"` // 公众号所设置的微信号
UpdateTime string `json:"updateTime"`
}
type MpListResp ¶
type MsgListResp ¶
type MsgListResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
Pager
List []struct {
TopicName string `json:"topicName"` // 群组名称,一对多消息才有值
MessageType int `json:"messageType"` // 消息类型;1-一对一消息,2-一对多消息
Title string `json:"title"` // 消息标题
ShortCode string `json:"shortCode"` // 消息短链码;可用于查询消息发送结果
Channel string `json:"channel"` // 消息发送渠道; wechat-微信公众号,mail-邮件,cp-企业微信应用,webhook-第三方webhook
UpdateTime string `json:"updateTime"` // 更新日期
} `json:"list"`
} `json:"data"`
}
type QrCodeResp ¶
type SendMsgCallbackResp ¶
type SendMsgReq ¶
type SendMsgReq struct {
Token string `json:"token"`
Title string `json:"title,omitempty"`
Content string `json:"content"`
Template string `json:"template,omitempty"` // 消息模板 html,json,cloudMonitor 默认 html
Topic string `json:"topic,omitempty"` // 群组编码,不填仅发送给自己;channel为webhook时无效
Channel string `json:"channel,omitempty"` // 发送渠道, wechat,webhook,cp 默认 wechat
Webhook string `json:"webhook,omitempty"`
CallbackUrl string `json:"callback_url,omitempty"` // 发送结果回调地址
Timestamp string `json:"timestamp,omitempty"` // 毫秒时间戳。格式如:1632993318000。服务器时间戳大于此时间戳,则消息不会发送
To string `json:"to,omitempty"` // 好友令牌,微信公众号渠道填写好友令牌,企业微信渠道填写企业微信用户id
}
type SendMsgResultResp ¶
type TopicAddReq ¶
type TopicAddResp ¶
type TopicDetailResp ¶
type TopicDetailResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
TopicId int `json:"topicId"`
TopicName string `json:"topicName"`
TopicCode string `json:"topicCode"`
QrCodeImgUrl string `json:"qrCodeImgUrl"`
Contact string `json:"contact"`
Introduction string `json:"introduction"`
ReceiptMessage string `json:"receiptMessage"`
CreateTime string `json:"createTime"`
TopicUserCount int `json:"topicUserCount"`
} `json:"data"`
}
type TopicJoinDetailResp ¶
type TopicJoinDetailResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
TopicName string `json:"topicName"`
TopicCode string `json:"topicCode"`
TopicId int `json:"topicId"`
Contact string `json:"contact"`
Introduction string `json:"introduction"`
CreateTime string `json:"createTime"`
} `json:"data"`
}
type TopicListReq ¶
type TopicListResp ¶
type TopicListResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
Pager
List []struct {
TopicId int `json:"topicId"` // 群组编号
TopicCode string `json:"topicCode"` // 群组编码
TopicName string `json:"topicName"` // 群组名称
CreateTime string `json:"createTime"` // 创建时间
} `json:"list"`
} `json:"data"`
}
type TopicUserListReq ¶
type TopicUserListResp ¶
type TopicUserListResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
Pager
List []struct {
Id int `json:"id"` // 用户编号;可用于删除用户
NickName string `json:"nickName"` // 昵称
OpenId string `json:"openId"` // 用户微信openId
HeadImgUrl string `json:"headImgUrl"` // 头像url地址
UserSex int `json:"userSex"` // 性别;0-未设置,1-男,2-女
HavePhone int `json:"havePhone"` // 是否绑定手机;0-未绑定,1-已绑定
IsFollow int `json:"isFollow"` // 是否关注微信公众号;0-未关注,1-已关注
EmailStatus int `json:"emailStatus"` // 邮箱验证状态;0-未验证,1-待验证,2-已验证
} `json:"list"`
} `json:"data"`
}
type UserInfo ¶
type UserInfo struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
OpenId string `json:"openId"` // 用户微信的openId
UnionId string `json:"unionId"` // 用户微信的unionId
NickName string `json:"nickName"` // 昵称
HeadImgUrl string `json:"headImgUrl"` // 头像
UserSex int `json:"userSex"` // 性别: 0-未设置,1-男,2-女
Token string `json:"token"` // 用户令牌
PhoneNumber string `json:"phoneNumber"` // 手机号
Email string `json:"email"` // 邮箱
EmailStatus int `json:"emailStatus"` // 邮箱验证状态;0-未验证,1-待验证,2-已验证
Birthday string `json:"birthday"` // 生日
Points float64 `json:"points"` // 用户积分
} `json:"data"`
}
type UserLimitTimeResp ¶
type UserSendCountResp ¶
type UserSendCountResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
WechatSendCount int `json:"wechatSendCount"` // 微信公众号渠道请求次数
CpSendCount int `json:"cpSendCount"` // 企业微信应用渠道请求次数
WebhookSendCount int `json:"webhookSendCount"` // webhook渠道请求次数
MailSendCount int `json:"mailSendCount"` // 邮件渠道请求次数
} `json:"data"`
}
type UserSetting ¶
type UserSetting struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
DefaultChannel string `json:"defaultChannel"` // 默认渠道编码
DefaultChannelTxt string `json:"defaultChannelTxt"` // 默认渠道名称
DefaultWebhook string `json:"defaultWebhook"` // webhook 参数
SendLimit int `json:"sendLimit"` // 发送限制;0-无限制,1-禁止所有渠道发送,2-限制微信渠道,3-限制邮件渠道
RecevieLimit int `json:"recevieLimit"` // 接收限制;0-接收全部,1-不接收消息
} `json:"data"`
}
type WebhookData ¶
type WebhookListResp ¶
type WebhookListResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
Pager
List []WebhookData `json:"list"`
} `json:"data"`
}
type WebhookReq ¶
type WebhookResp ¶
type WebhookResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data WebhookData `json:"data"`
}