commons

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UploadMediaURL  string = "https://qyapi.weixin.qq.com/cgi-bin/media/upload"
	UploadImgURL    string = "https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg"
	GetMediaURL     string = "https://qyapi.weixin.qq.com/cgi-bin/media/get"
	GetHighVoiceURL string = "https://qyapi.weixin.qq.com/cgi-bin/media/get/jssdk"
)

参考https://work.weixin.qq.com/api/doc/90000/90135/91054

View Source
const (
	ContactsID = "qywx001" // 企业微信通讯录
)

企业微信中一些应用没有agentid,这里设置常量

View Source
const (
	ErrParamInValid string = "参数不正确"
)

常用的错误

Variables

This section is empty.

Functions

func DecodeWithCommonError

func DecodeWithCommonError(response []byte, apiName string) (err error)

DecodeWithCommonError 将返回值按照CommonError解析

func DecodeWithError

func DecodeWithError(response []byte, obj interface{}, apiName string) error

DecodeWithError 将返回值按照解析

func GetAPIDomainIP

func GetAPIDomainIP(accessToken string) ([]string, error)

GetAPIDomainIP 获取企业微信API域名IP段 参考https://open.work.weixin.qq.com/api/doc/90000/90135/92520

func GetCallBackIP

func GetCallBackIP(accessToken string) ([]string, error)

GetCallBackIP 获取企业微信回调IP地址列表 参考https://open.work.weixin.qq.com/api/doc/90000/90135/90930#3.3%20%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84ip%E6%AE%B5

func GetHighVoice

func GetHighVoice(accessToken string, mediaid string) ([]byte, error)

GetHighVoice 获取高清语音素材 https://work.weixin.qq.com/api/doc/90000/90135/90255

func GetMedia

func GetMedia(accessToken string, mediaid string) ([]byte, error)

GetMedia 获取临时素材 https://work.weixin.qq.com/api/doc/90000/90135/90254

func HTTPGet

func HTTPGet(uri string) ([]byte, error)

HTTPGet get 请求

func HTTPPost

func HTTPPost(uri string, data string) ([]byte, error)

HTTPPost post 请求

func PostFile

func PostFile(fieldname, filename, uri string) ([]byte, error)

PostFile 上传文件

func PostJSON

func PostJSON(uri string, obj interface{}) ([]byte, error)

PostJSON post json 数据请求

func PostJSONWithRespContentType

func PostJSONWithRespContentType(uri string, obj interface{}) ([]byte, string, error)

PostJSONWithRespContentType post json数据请求,且返回数据类型

func PostMultipartForm

func PostMultipartForm(fields []MultipartFormField, uri string) (respBody []byte, err error)

PostMultipartForm 上传文件或其他多个字段

func PostXML

func PostXML(uri string, obj interface{}) ([]byte, error)

PostXML perform a HTTP/POST request with XML body

func PostXMLWithTLS

func PostXMLWithTLS(uri string, obj interface{}, ca, key string) ([]byte, error)

PostXMLWithTLS perform a HTTP/POST request with XML body and TLS

Types

type APIDomainIPResp

type APIDomainIPResp struct {
	CommonError
	IPList []string `json:"ip_list"`
}

APIDomainIPResp 企业微信服务器IP返回结果

type CommonError

type CommonError struct {
	ErrCode int64  `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

CommonError 微信返回的通用错误json

type MultipartFormField

type MultipartFormField struct {
	IsFile    bool
	Fieldname string
	Value     []byte
	Filename  string
}

MultipartFormField 保存文件或其他字段信息

type QywxConfig

type QywxConfig struct {
	CorpID  string // corpid 企业微信ID
	AgentID string // 应用ID
	Secret  string // 应用秘钥

}

QywxConfig 企业微信配置

type UploadImgResp

type UploadImgResp struct {
	CommonError
	URL string `jsong:"url"`
}

UploadImgResp 上传图片响应

func UploadImg

func UploadImg(accessToken string, filename string) (*UploadImgResp, error)

UploadImg 上传图片 https://work.weixin.qq.com/api/doc/90000/90135/90256

type UploadMediaResp

type UploadMediaResp struct {
	CommonError
	Type      string `json:"type"`
	MediaID   string `json:"media_id"`
	CreatedAt string `json:"created_at"`
}

UploadMediaResp 上传临时素材响应

func UploadMedia

func UploadMedia(accessToken string, mediaType string, filename string) (*UploadMediaResp, error)

UploadMedia 上传临时素材 https://work.weixin.qq.com/api/doc/90000/90135/90253

Jump to

Keyboard shortcuts

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