123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
-
-
- package authorizer
-
- import (
- "encoding/json"
- "net/url"
-
- "gitee.com/yansen_zh/wxcomponent/config"
- "gitee.com/yansen_zh/wxcomponent/errors"
- "gitee.com/yansen_zh/wxcomponent/utils/request"
- )
-
-
- type AuthorizerListResult struct {
- errors.Error
- TotalCount int `json:"total_count"`
- List []AuthorizerBasicInfo `json:"list"`
- }
-
- const (
- apiGetAuthorizerList = "https://apies.weixin.qq.com/cgi-bin/component/api_get_authorizer_list"
- )
-
-
- func GetAuthorizerList(offset, count int) (*AuthorizerListResult, error) {
- if offset < 0 {
- offset = 0
- }
-
- if count < 0 {
- count = 100
- }
-
- if count > 500 {
- count = 500
- }
-
- queryParam := url.Values{}
- queryParam.Set("component_access_token", config.GetAccessToken())
-
- data := map[string]interface{}{
- "component_appid": config.GetAppID(),
- "offset": offset,
- "count": count,
- }
-
- resp, e2 := request.PostJSON(apiGetAuthorizerList, &queryParam, data)
- if e2 != nil {
- return nil, e2
- }
-
- result := AuthorizerListResult{}
- if err := json.Unmarshal(resp, &result); err != nil {
- return nil, err
- }
-
- return &result, nil
- }
|