This commit is contained in:
suyl
2021-06-17 14:32:39 +08:00
parent 3ed374e74a
commit f746cd1023
13 changed files with 191 additions and 18 deletions

View File

@@ -7,6 +7,11 @@ const (
ticketType = "wx_card"
authType = 0 //Int 是 授权类型0开票授权1填写字段开票授权2领票授权
//图片image、视频video、语音 voice、图文news
MaterialTypeImage = "image"
MaterialTypeVideo = "video"
MaterialTypeVoice = "voice"
MaterialTypeNews = "news"
)
type CBUserInfo struct {
@@ -115,3 +120,52 @@ func (a *API) CBGetTicketInfo() (ticketInfo *CBTicketInfo, err error) {
}
return ticketInfo, err
}
type CBBatchgetMaterialResult struct {
Item []struct {
MediaID string `json:"media_id"`
Content struct {
NewsItem []struct {
Title string `json:"title"`
Author string `json:"author"`
Digest string `json:"digest"`
Content string `json:"content"`
ContentSourceURL string `json:"content_source_url"`
ThumbMediaID string `json:"thumb_media_id"`
ShowCoverPic int `json:"show_cover_pic"`
URL string `json:"url"`
ThumbURL string `json:"thumb_url"`
NeedOpenComment int `json:"need_open_comment"`
OnlyFansCanComment int `json:"only_fans_can_comment"`
} `json:"news_item"`
CreateTime int `json:"create_time"`
UpdateTime int `json:"update_time"`
} `json:"content"`
UpdateTime int `json:"update_time"`
} `json:"item"`
TotalCount int `json:"total_count"`
ItemCount int `json:"item_count"`
}
//获取素材列表
func (a *API) CBBatchgetMaterial(mediaType string, offset, count int) (ticketInfo *CBBatchgetMaterialResult, err error) {
bodyJson := map[string]interface{}{
"type": mediaType,
"offset": offset,
"count": count,
}
result, err := a.AccessAPI("cgi-bin/material/batchget_material", nil, string(utils.MustMarshal(bodyJson)))
if err == nil {
err = utils.Map2StructByJson(result, &ticketInfo, false)
}
return ticketInfo, err
}
//上传图片
func (a *API) CBUploadImg(data []byte, fileName, contentType string) (url string, err error) {
result, err := a.AccessAPIUpload(data, fileName, contentType)
if err == nil {
return result["url"].(string), err
}
return url, err
}