yxsdk

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

* The MIT License (MIT) * * Copyright (c) 2016 tony<wuhaiyang1213@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software.

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.

* The MIT License (MIT) * * Copyright (c) 2016 tony<wuhaiyang1213@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software.

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.

* The MIT License (MIT) * * Copyright (c) 2016 tony<wuhaiyang1213@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software.

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.

* The MIT License (MIT) * * Copyright (c) 2016 tony<wuhaiyang1213@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software.

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.

* The MIT License (MIT) * * Copyright (c) 2016 tony<wuhaiyang1213@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software.

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.

Index

Constants

View Source
const NETEASE_BASE_URL = "https://api.netease.im/nimserver"

Variables

View Source
var APPKEY = viper.GetString("im.app_key")
View Source
var APPSECRETKEY = viper.GetString("im.app_secret")
View Source
var BLOCK_URL = UrlPair{"POST", NETEASE_BASE_URL + "/user/block.action"}
View Source
var CREATE_ACCOUNT_ID_URL = UrlPair{"POST", NETEASE_BASE_URL + "/user/create.action"}
View Source
var DELETEFRIEND_URL = UrlPair{"POST", NETEASE_BASE_URL + "/friend/delete.action"}
View Source
var FRIENDSHIP_URL = UrlPair{"POST", NETEASE_BASE_URL + "/friend/add.action"}
View Source
var GETUINFOS_URL = UrlPair{"POST", NETEASE_BASE_URL + "/user/getUinfos.action"}
View Source
var GET_GROUP_INFO = UrlPair{"POST", NETEASE_BASE_URL + "/team/joinTeams.action"}
View Source
var GET_PROFILE_URL = UrlPair{"POST", NETEASE_BASE_URL + "/user/getUinfos.action"}
View Source
var GROUP_LIST_URL = UrlPair{"POST", NETEASE_BASE_URL + "/team/query.action"}
View Source
var QUERYFRIEND_URL = UrlPair{"POST", NETEASE_BASE_URL + "/friend/get.action"}
View Source
var REFRESH_TOKEN_URL = UrlPair{"POST", NETEASE_BASE_URL + "/user/refreshToken.action"}
View Source
var SENDMSG_ATTACH_MSG = UrlPair{"POST", NETEASE_BASE_URL + "/msg/sendBatchAttachMsg.action"}
View Source
var SENDMSG_BATCH_URL = UrlPair{"POST", NETEASE_BASE_URL + "/msg/sendBatchMsg.action"}
View Source
var SENDMSG_URL = UrlPair{"POST", NETEASE_BASE_URL + "/msg/sendMsg.action"}
View Source
var SPECIALRELATION_URL = UrlPair{"POST", NETEASE_BASE_URL + "/user/setSpecialRelation.action"}
View Source
var UNBLOCK_URL = UrlPair{"POST", NETEASE_BASE_URL + "/user/unblock.action"}
View Source
var UPDATEFRIEND_URL = UrlPair{"POST", NETEASE_BASE_URL + "/friend/update.action"}
View Source
var UPDATE_ACCOUNT_ID_URL = UrlPair{"POST", NETEASE_BASE_URL + "/user/update.action"}
View Source
var UPDATE_PROFILE_URL = UrlPair{"POST", NETEASE_BASE_URL + "/user/updateUinfo.action"}
View Source
var UPDATE_USER_INFO_URL = UrlPair{"POST", NETEASE_BASE_URL + "/user/updateUinfo.action"}

Functions

func AddFriend

func AddFriend(accid string, faccid string, typ int, msg string) error

云信平台用户关系托管 accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一(只允许字母、数字、半角下划线_、@、半角点以及半角-组成, 不区分大小写, 会统一小写处理,请注意以此接口返回结果中的accid为准) friendid string 好友云信ID typ int 1直接加好友,2请求加好友,3同意加好友,4拒绝加好友 msg string 加好友对应的请求消息,第三方组装,最长256字符

func AddNeteaseHttpHeader

func AddNeteaseHttpHeader(req *http.Request)

在HttpHeader中添加参数用于校验

func Block

func Block(accid string) (string, error)

封禁云信ID 第三方禁用某个云信ID的IM功能,封禁云信ID后,此ID将不能登陆云信imserver accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一

func DelFriend

func DelFriend(accid string, faccid string, isDeleteAlias bool) error

云信平台用户关系托管 accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一(只允许字母、数字、半角下划线_、@、半角点以及半角-组成, 不区分大小写, 会统一小写处理,请注意以此接口返回结果中的accid为准) friendid string 要删除朋友的accid

func DoNeteaseHttpRequest

func DoNeteaseHttpRequest(v url.Values, reqMethod string, reqUrl string) (string, error)

执行云信http请求

func GetCheckSum

func GetCheckSum(appSecret string, nonce string, curTime string) string

func GetGroupInfo

func GetGroupInfo(ope int, tids ...string) (string, error)

func Init

func Init(appKey string, appSecretKey string)

func QueryFriend

func QueryFriend(accid string, updatetime string, createtime string) (string, error)

1.查询某时间点起到现在有更新的双向好友 accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一(只允许字母、数字、半角下划线_、@、半角点以及半角-组成, 不区分大小写, 会统一小写处理,请注意以此接口返回结果中的accid为准) updatetime Long 必须 更新时间戳,接口返回该时间戳之后有更新的好友列表 createtime Long 不必须 【Deprecated】定义同updatetime

func RefreshToken

func RefreshToken(accid string) (string, error)

更新并获取新token WebServer更新云信ID的token,同时返回新的token accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一

func SendAttachMsg

func SendAttachMsg(msg yxsdk_rq.MessageAttachRq) (string, error)

func SendBatchMsg

func SendBatchMsg(msg yxsdk_rq.MessageBatchRq) (string, error)

func Unblock

func Unblock(accid string) (string, error)

解禁云信ID 解禁被封禁的云信ID accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一

func UpdateAccid

func UpdateAccid(accid string, name string, props string, icon string, token string) (string, error)

云信ID更新 云信ID基本信息更新 accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一(只允许字母、数字、半角下划线_、@、半角点以及半角-组成, 不区分大小写, 会统一小写处理,请注意以此接口返回结果中的accid为准) name string 云信ID昵称,最大长度64字节,用来PUSH推送 时显示的昵称 props string json属性,第三方可选填,最大长度1024字节 icon string 云信ID头像URL,第三方可选填,最大长度1024 token string 云信ID可以指定登录token值,最大长度128字节, 并更新,如果未指定,会自动生成token,并在创建成功后返回

func UpdateFriendInfo

func UpdateFriendInfo(accid, faccid, alias, ex, serverex string) error

func UpdateProfile

func UpdateProfile(accid string, name string, icon string, sign string, email string, birth string, mobile string, gender string, ex string) (bool, error)

更新用户名片 accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一 name string 用户昵称,最大长度64字节 icon string 用户icon,最大长度1024字节 sign string 用户签名,最大长度256字节 email string 用户email,最大长度64字节 birth string 用户生日,最大长度16字节 mobile string 用户mobile,最大长度32字节 gender string 用户性别,0表示未知,1表示男,2女表示女,其它会报参数错误 ex string 用户名片扩展字段,最大长度1024字节,用户可自行扩展,建议封装成JSON字符串

func UpdateUserInfo

func UpdateUserInfo(accid, name, icon, sign, email, birth, mobile, gender, ex string) error

更新用户名片 更新用户名片。用户名片中包含的用户信息,在群组、聊天室等场景下,会暴露给群组、聊天室内的其他用户。 这些字段里mobile,email,birth,gender等字段属于非必填、可能涉及隐私的信息,如果您的业务下, 这些信息为敏感信息,建议在通过扩展字段ex填写相关资料并事先加密。 参数 类型 必须 说明 accid String 是 用户帐号,最大长度32字符,必须保证一个APP内唯一 name String 否 用户昵称,最大长度64字符,可设置为空字符串 icon String 否 用户头像,最大长度1024字节,可设置为空字符串 sign String 否 用户签名,最大长度256字符,可设置为空字符串 email String 否 用户email,最大长度64字符,可设置为空字符串 birth String 否 用户生日,最大长度16字符,可设置为空字符串 mobile String 否 用户mobile,最大长度32字符,非中国大陆手机号码需要填写国家代码(如美国:+1-xxxxxxxxxx)或地区代码(如香港:+852-xxxxxxxx),可设置为空字符串 gender int 否 用户性别,0表示未知,1表示男,2女表示女,其它会报参数错误 ex String 否 用户名片扩展字段,最大长度1024字符,用户可自行扩展,建议封装成JSON字符串,也可以设置为空字符串

Types

type ErrorData

type ErrorData struct {
	Desc string
}

type ErrorResp

type ErrorResp struct {
	NetEaseResp
	ErrorData
}

type GroupInfo

type GroupInfo struct {
	Owner string `json:"owner"`
	Tname string `json:"tname"`
	Tid   int    `json:"tid"`
	Size  int    `json:"size"`
}

func GetPersonalGroupInfo

func GetPersonalGroupInfo(accid string) ([]GroupInfo, error)

type GroupInfoResp

type GroupInfoResp struct {
	NetEaseResp
	Uinfos []GroupInfo `json:"infos"`
	Desc   string
}

type MsgBatchData

type MsgBatchData struct {
	Msgids     jsongo.O
	Unregister []string
}

type MsgData

type MsgData struct {
	Msgid    wph.Long
	Antispam bool
}

func SendMsg

func SendMsg(msg yxsdk_rq.MessageRq) (*MsgData, error)

发送云信消息

type NIMGetProfileResp

type NIMGetProfileResp struct {
	NetEaseResp
	Uinfos []NIMUserProfile
}

type NIMUInfo

type NIMUInfo struct {
	Accid string //云信ID
	Name  string //云信ID昵称,最大长度64字节,用来PUSH推送时显示的昵称
	Icon  string //云信ID头像URL,第三方可选填,最大长度1024
	Token string //token
}

func CreateAccid

func CreateAccid(accid string, name string, props string, icon string, token string, ex string) (*NIMUInfo, error)

创建云信ID 第三方帐号导入到云信平台 accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一(只允许字母、数字、半角下划线_、@、半角点以及半角-组成, 不区分大小写, 会统一小写处理,请注意以此接口返回结果中的accid为准) name string 云信ID昵称,最大长度64字节,用来PUSH推送 时显示的昵称 props string json属性,第三方可选填,最大长度1024字节 icon string 云信ID头像URL,第三方可选填,最大长度1024 token string 云信ID可以指定登录token值,最大长度128字节, 并更新,如果未指定,会自动生成token,并在创建成功后返回

func GetUserInfo

func GetUserInfo(accids ...string) ([]NIMUInfo, error)

获取用户信息 accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一

type NIMUserProfile

type NIMUserProfile struct {
	NIMUInfo
	Sign   string //用户签名,最大长度256字节
	Emai   string //用户email,最大长度64字节
	Birth  string //用户生日,最大长度16字节
	Mobile string //用户mobile,最大长度32字节,只支持国内号码
	Gender int    //用户性别,0表示未知,1表示男,2女表示女,其它会报参数错误
	Ex     string //用户名片扩展字段,最大长度1024字节,用户可自行扩展,建议封装成JSON字符串
}

func GetProfile

func GetProfile(accids []string, appkey string, appSecret string) ([]NIMUserProfile, error)

获取用户名片 获取用户名片,可批量 accId string 云信ID,最大长度32字节,必须保证一个 APP内唯一

type NetEaseResp

type NetEaseResp struct {
	Code int //状态码
}

type UrlPair

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

Jump to

Keyboard shortcuts

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