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/cgi-bin.get_api_domain_ip.go

39 lines
1.4 KiB

2 years ago
package wechatopen
import (
2 years ago
"context"
1 year ago
"github.com/dtapps/go-library/utils/gojson"
2 years ago
"github.com/dtapps/go-library/utils/gorequest"
2 years ago
"net/http"
)
type GetCallBackIpResponse struct {
12 months ago
IpList []string `json:"ip_list,omitempty"`
2 years ago
}
type GetCallBackIpResult struct {
Result GetCallBackIpResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
2 years ago
}
func NewGetCallBackIpResult(result GetCallBackIpResponse, body []byte, http gorequest.Response) *GetCallBackIpResult {
return &GetCallBackIpResult{Result: result, Body: body, Http: http}
2 years ago
}
12 months ago
// CgiBinGetApiDomainIp 获取微信API接口 IP地址
2 years ago
// https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_the_WeChat_server_IP_address.html
func (c *Client) CgiBinGetApiDomainIp(ctx context.Context, componentAccessToken string, notMustParams ...gorequest.Params) (*GetCallBackIpResult, error) {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
2 years ago
// 请求
request, err := c.request(ctx, apiUrl+"/cgi-bin/get_api_domain_ip?access_token="+componentAccessToken, params, http.MethodGet)
if err != nil {
return NewGetCallBackIpResult(GetCallBackIpResponse{}, request.ResponseBody, request), err
}
2 years ago
// 定义
var response GetCallBackIpResponse
1 year ago
err = gojson.Unmarshal(request.ResponseBody, &response)
return NewGetCallBackIpResult(response, request.ResponseBody, request), err
2 years ago
}