material

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client 媒体管理实例

func NewClient

func NewClient(cfg *config.Config) (client *Client, err error)

NewClient 初始化媒体管理

func (*Client) GetMediaURL

func (r *Client) GetMediaURL(mediaID string) (mediaURL string, err error)

GetMediaURL 返回临时素材的下载地址供用户自己处理 NOTICE: URL 不可公开,因为含access_token 需要立即另存文件

func (*Client) ImageUpload

func (r *Client) ImageUpload(filename string) (url string, err error)

ImageUpload 图片上传

func (*Client) MediaUpload

func (r *Client) MediaUpload(mediaType MediaType, filename string) (media Media, err error)

MediaUpload 临时素材上传

type Error

type Error string

Error 错误

const (
	// SDKInitFailed 错误码:50001
	SDKInitFailed Error = "SDK初始化失败"
	// SDKCacheUnavailable 错误码:50002
	SDKCacheUnavailable Error = "缓存无效"
	// SDKUnknownError 错误码:50003
	SDKUnknownError Error = "未知错误"
	// SDKInvalidCredential 错误码:40001
	SDKInvalidCredential Error = "不合法的secret参数"
	// SDKInvalidCorpID 错误码:40013
	SDKInvalidCorpID Error = "无效的 CorpID"
	// SDKAccessTokenInvalid 错误码:40014
	SDKAccessTokenInvalid Error = "AccessToken 无效"
	// SDKValidateSignatureFailed 错误码:40015
	SDKValidateSignatureFailed Error = "校验签名错误"
	// SDKDecryptMSGFailed 错误码:40016
	SDKDecryptMSGFailed Error = "消息解密失败"
	// SDKAccessTokenMissing 错误码:41001
	SDKAccessTokenMissing Error = "缺少AccessToken参数"
	// SDKAccessTokenExpired 错误码:42001
	SDKAccessTokenExpired Error = "AccessToken 已过期"
	// SDKApiFreqOutOfLimit 错误码:45009
	SDKApiFreqOutOfLimit Error = "接口请求次数超频"
	// SDKApiForbidden 错误码:48002
	SDKApiForbidden Error = "API 禁止调用"
	// SDKInvalidOpenKFID 错误码:95000
	SDKInvalidOpenKFID Error = "无效的 open_kfid"
	// SDKOpenKFIDNotExist 错误码:95004
	SDKOpenKFIDNotExist Error = "open_kfid 不存在"
	// SDKWeWorkAlready 错误码:95011
	SDKWeWorkAlready Error = "已在企业微信使用微信客服"
	// SDKNotUseInWeCom 错误码:95012
	SDKNotUseInWeCom Error = "未在企业微信使用微信客服"
	// SDKApiNotOpen 错误码:95017
	SDKApiNotOpen Error = "API 功能没有被开启"
)

func NewSDKErr

func NewSDKErr(code int64, msgList ...string) Error

NewSDKErr 初始化SDK实例错误信息

func (Error) Error

func (r Error) Error() string

Error 输出错误信息

type Media

type Media struct {
	util.CommonError

	Type         MediaType `json:"type"`
	MediaID      string    `json:"media_id"`
	ThumbMediaID string    `json:"thumb_media_id"`
	CreatedAt    string    `json:"created_at"`
}

Media 临时素材上传返回信息

type MediaType

type MediaType string

MediaType 媒体文件类型

const (
	// MediaTypeImage 媒体文件:图片
	MediaTypeImage MediaType = "image"
	// MediaTypeVoice 媒体文件:声音
	MediaTypeVoice MediaType = "voice"
	// MediaTypeVideo 媒体文件:视频
	MediaTypeVideo MediaType = "video"
	// MediaTypeFile 媒体文件:文件
	MediaTypeFile MediaType = "file"
)

Jump to

Keyboard shortcuts

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