jmessage

package
v0.0.0-...-4a63d6d Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KEY_LENGTH   = 24
	CONN_TIMEOUT = 5
	RW_TIMEOUT   = 30
)
View Source
const (
	JMESSAGE_IM_URL  = "https://api.im.jpush.cn" //IM server
	REGIST_USER_URL  = "/v1/users/"              //user url
	REGIST_ADMIN_URL = "/v1/admins/"             //admin url
	MESSAGES_URL     = "/v1/messages"            //message url
	GROUPS_URL       = "/v1/groups/"             //group url

	JMESSAGE_REPORT_V2_URL = "https://report.im.jpush.cn/v2" //REST Report V2
	REPORT_MESSAGE         = "/messages"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JMError

type JMError struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

func (*JMError) Error

func (e *JMError) Error() string

type JMResponse

type JMResponse struct {
	Error *JMError `json:"error,omitempty"`
}

type JMUser

type JMUser struct {
	Username  string `json:"username"`            //(必填 Byte(4~128) 开头:字母或者数字 字母、数字、下划线英文点、减号、@
	Password  string `json:"password"`            //(必填) Byte(4~128) 用户密码。极光IM服务器会MD5加密保存
	Nickname  string `json:"nickname,omitempty"`  //Byte(0~64) 不支持的字符:英文字符: \n \r\n
	Avatar    string `json:"avatar,omitempty"`    //(选填)头像 需要填上从文件上传接口获得的media_id
	Birthday  string `json:"star,omitempty"`      //(选填)生日 example: 1990-01-24
	Gender    int    `json:"gender,omitempty"`    //性别 0 - 未知, 1 - 男 ,2 - 女
	Signature string `json:"signature,omitempty"` //用户签名 Byte(0~250)
	Region    string `json:"region,omitempty"`    //(选填)地区 用户所属地区 Byte(0~250)
	Address   string `json:"address,omitempty"`   //(选填)地址 用户详细地址	Byte(0~250)
	Mtime     int    `json:"mtime,omitempty"`     //用户最后修改时间
	Ctime     int    `json:"ctime,omitempty"`     //用户创建时间

	Error *JMError `json:"error,omitempty"`
}

JMUser 用户信息 返回信息

type JMessageClient

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

func NewJMessageClient

func NewJMessageClient(appkey, master_secret string, debug bool) *JMessageClient

NewJMessageClient 创建client

func (*JMessageClient) BlackUsers

func (jclient *JMessageClient) BlackUsers(fromUsername string, blackUserNames []string) error

BlackUsers 添加黑名单

func (*JMessageClient) DeleteBlackUsers

func (jclient *JMessageClient) DeleteBlackUsers(fromUsername string, blackUserNames []string) error

DeleteBlackUsers 删除黑名单

func (*JMessageClient) DeleteUser

func (jclient *JMessageClient) DeleteUser(username string) error

func (*JMessageClient) ForbiddenUser

func (jclient *JMessageClient) ForbiddenUser(username string, forbidden bool) error

ForbiddenUser 禁用/解除禁用

func (*JMessageClient) GetBlackUsers

func (jclient *JMessageClient) GetBlackUsers(fromUsername string) ([]string, error)

GetBlackUsers 获取黑名单

func (*JMessageClient) GetMessages

func (jclient *JMessageClient) GetMessages(count int, beginTime, endTime string, cursor string) (*JPMessageList, error)

GetMessages 获取消息 count (必填)每次查询的总条数 一次最多1000 begin_time (必填) 记录开始时间 格式 yyyy-MM-dd HH:mm:ss 设置筛选条件大于等于begin time end_time (必填) 记录结束时间 格式 yyyy-MM-dd HH:mm:ss 设置筛选条件小于等于end time begin_time end_time 之间最大范围不得超过7天 cursor 当第一次请求后如果后面有数据,会返回一个cursor回来用这个获取接下来的消息 (cursor 有效时间是120s,过期后需要重新通过第一个请求获得cursor,重新遍历) 查询的消息按发送时间升序排序

func (*JMessageClient) GetUserMessages

func (jclient *JMessageClient) GetUserMessages(userName string, count int, beginTime, endTime string, cursor string) (*JPMessageList, error)

GetUserMessages 用户消息

func (*JMessageClient) RegisterAdmin

func (jclient *JMessageClient) RegisterAdmin(username string,
	nickName string,
	password string,
	avatar string) (*JMUser, *JMError, error)

func (*JMessageClient) RegisterUser

func (jclient *JMessageClient) RegisterUser(username string,
	nickName string,
	password string,
	avatar string) (*JMUser, *JMError, error)

RegisterUser 注册用户

func (*JMessageClient) RegisterUsers

func (jclient *JMessageClient) RegisterUsers(users []*JMUser) ([]*JMUser, error)

RegisterUsers 批量注册用户

func (*JMessageClient) SentSystemTxtMsg

func (jclient *JMessageClient) SentSystemTxtMsg(fromId string,
	targetType string,
	targetId string,
	message string, ext map[string]interface{}) error

SentSystemTxtMsg 发送系统文本消息

func (*JMessageClient) UpdatePasswd

func (jclient *JMessageClient) UpdatePasswd(username string, passwd string) error

func (*JMessageClient) UpdateProfile

func (jclient *JMessageClient) UpdateProfile(username string, nickname, avatar, birthday string,
	signature, gender, region, address string,
	extras string) error

type JPIMGMsg

type JPIMGMsg struct {
	MediaId    string `json:"media_id"`    //String 文件上传之后服务器端所返回的key,用于之后生成下载的url(必填)
	MediaCrc32 int64  `json:"media_crc32"` //long 文件的crc32校验码,用于下载大图的校验 (必填)

	Format string `json:"format"`         //String 图片格式(必填)
	Hash   string `json:"hash,omitempty"` //String 图片hash值(可选)
	Fsize  int    `json:"fsize"`          //(必填)
	// contains filtered or unexported fields
}

JPIMGMsg 消息

type JPMessage

type JPMessage struct {
	Version    int    `json:"version"`     //版本号 目前是1 (必填)
	TargetType string `json:"target_type"` //发送目标类型 single - 个人,group - 群组 chatroom - 聊天室(必填)
	TargetId   string `json:"target_id"`   //目标id single填username group 填Group id chatroom 填chatroomid(必填)
	FromType   string `json:"from_type"`   //发送消息者身份 当前只限admin用户,必须先注册admin用户 (必填)
	FromId     string `json:"from_id"`     //发送者的username (必填)

	MsgType string                 `json:"msg_type"` //发消息类型 text - 文本,image - 图片, custom - 自定义消息(msg_body为json对象即可,服务端不做校验)voice - 语音 (必填)
	MsgBody map[string]interface{} `json:"msg_body"`

	FromName       string          `json:"from_name,omitempty"`       //发送者展示名(选填)
	TargetName     string          `json:"target_name,omitempty"`     //接受者展示名(选填)
	NoOffline      string          `json:"no_offline,omitempty"`      //消息是否离线存储 true或者false,默认为false,表示需要离线存储(选填)
	NoNotification bool            `json:"no_notification,omitempty"` //消息是否在通知栏展示 true或者false,默认为false,表示在通知栏展示(选填)
	Notification   *JPNotification `json:"notification,omitempty"`    //自定义通知栏展示(选填)

	MsgId    int64 `json:"msgid,omitempty"`     //消息id
	MsgLevel uint8 `json:"msg_level,omitempty"` // 0代表应用内消息 1代表跨应用消息
	MsgCtime int64 `json:"msg_ctime,omitempty"` // 服务器接收到消息的时间,单位毫秒

}

JPMessage 消息

type JPMessageBody

type JPMessageBody interface {
	// contains filtered or unexported methods
}

JMsg RCMsg接口

type JPMessageList

type JPMessageList struct {
	Total    int64       `json:"total"`
	Cursor   string      `json:"cursor"`
	Count    int64       `json:"count"`
	Messages []JPMessage `json:"messages,omitempty"`
}

JPMessageList 消息列表

type JPNotification

type JPNotification struct {
	Title string `json:"title,omitempty"` //通知的标题(选填)
	Alert string `json:"alert,omitempty"` //通知的内容(选填)
}

JPNotification 消息

type JPTxtMsg

type JPTxtMsg struct {
	Text  string                 `json:"text"`            //消息内容 (必填)
	Extra map[string]interface{} `json:"extra,omitempty"` //选填的json对象 开发者可以自定义extras里面的key value(选填)
}

JPTxtMsg 消息

type JPVoiceMsg

type JPVoiceMsg struct {
	MediaId    string `json:"media_id"`       //String 文件上传之后服务器端所返回的key,用于之后生成下载的url(必填)
	MediaCrc32 int64  `json:"media_crc32"`    //long 文件的crc32校验码,用于下载大图的校验 (必填)
	Duration   int    `json:"duration"`       //int 音频时长(必填)
	Hash       string `json:"hash,omitempty"` //String 音频hash值(可选)
	Fsize      int    `json:"fsize"`          //(必填)
}

JPVoiceMsg 消息

Jump to

Keyboard shortcuts

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