123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
-
-
- package authorization
-
- 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 AuthorizerInfoResult struct {
- errors.Error
- AuthorizationInfo AuthorizationInfo `json:"authorization_info"`
- AuthorizerInfo AuthorizerInfo `json:"authorizer_info"`
- }
-
- const (
- apiGetAuthorizerInfo = "https://apies.weixin.qq.com/cgi-bin/component/api_get_authorizer_info"
- )
-
-
- func GetAuthorizerInfo(authorizerAppID string) (*AuthorizerInfoResult, error) {
- if authorizerAppID == "" {
- return nil, errors.New("获取授权帐号信息 授权方 appid 不能为空")
- }
-
- queryParam := url.Values{}
- queryParam.Set("component_access_token", config.GetAccessToken())
-
- data := map[string]string{
- "component_appid": config.GetAppID(),
- "authorizer_appid": authorizerAppID,
- }
-
- resp, e2 := request.PostJSON(apiGetAuthorizerInfo, &queryParam, data)
- if e2 != nil {
- return nil, e2
- }
-
- result := AuthorizerInfoResult{}
- if err := json.Unmarshal(resp, &result); err != nil {
- return nil, err
- }
-
- return &result, nil
- }
|