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.get_page.go

54 lines
1.5 KiB

2 years ago
package wechatopen
import (
2 years ago
"context"
2 years ago
"encoding/json"
"fmt"
2 years ago
"github.com/dtapps/go-library/utils/gorequest"
2 years ago
"net/http"
)
type WxaGetPageResponse struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
PageList []string `json:"page_list"` // page_list 页面配置列表
}
type WxaGetPageResult struct {
Result WxaGetPageResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
2 years ago
}
2 years ago
func newWxaGetPageResult(result WxaGetPageResponse, body []byte, http gorequest.Response) *WxaGetPageResult {
return &WxaGetPageResult{Result: result, Body: body, Http: http}
2 years ago
}
// WxaGetPage 获取已上传的代码的页面列表
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_page.html
func (c *Client) WxaGetPage(ctx context.Context, notMustParams ...gorequest.Params) (*WxaGetPageResult, error) {
2 years ago
// 检查
err := c.checkComponentIsConfig()
if err != nil {
return nil, err
}
err = c.checkAuthorizerIsConfig()
if err != nil {
return nil, err
}
// 参数
params := gorequest.NewParamsWith(notMustParams...)
2 years ago
// 请求
2 years ago
request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/wxa/get_page?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodGet)
if err != nil {
return nil, err
}
2 years ago
// 定义
var response WxaGetPageResponse
err = json.Unmarshal(request.ResponseBody, &response)
2 years ago
if err != nil {
return nil, err
}
return newWxaGetPageResult(response, request.ResponseBody, request), nil
2 years ago
}