You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/service/wechatopen/wxa.gettemplatelist.go

46 lines
2.1 KiB

2 years ago
package wechatopen
import (
"encoding/json"
"fmt"
"net/http"
)
type WxaGetTemplateListResponse struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
TemplateList []struct {
CreateTime int `json:"create_time"` // 被添加为模板的时间
UserVersion string `json:"user_version"` // 模板版本号,开发者自定义字段
UserDesc string `json:"user_desc"` // 模板描述,开发者自定义字段
TemplateId int64 `json:"template_id"` // 模板 id
TemplateType int `json:"template_type"` // 0对应普通模板1对应标准模板
SourceMiniprogramAppid string `json:"source_miniprogram_appid"` // 开发小程序的appid
SourceMiniprogram string `json:"source_miniprogram"` // 开发小程序的名称
Developer string `json:"developer"` // 开发者
CategoryList []interface{} `json:"category_list"`
} `json:"template_list"` // 模板信息列表
}
type WxaGetTemplateListResult struct {
Result WxaGetTemplateListResponse // 结果
Body []byte // 内容
Err error // 错误
}
func NewWxaGetTemplateListResult(result WxaGetTemplateListResponse, body []byte, err error) *WxaGetTemplateListResult {
return &WxaGetTemplateListResult{Result: result, Body: body, Err: err}
}
// WxaGetTemplateList 获取代码模板列表
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/code_template/gettemplatelist.html
func (app *App) WxaGetTemplateList() *WxaGetTemplateListResult {
app.componentAccessToken = app.GetComponentAccessToken()
// 请求
body, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/gettemplatelist?access_token=%s", app.componentAccessToken), map[string]interface{}{}, http.MethodGet)
// 定义
var response WxaGetTemplateListResponse
err = json.Unmarshal(body, &response)
return NewWxaGetTemplateListResult(response, body, err)
}