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.
35 lines
1.2 KiB
35 lines
1.2 KiB
2 years ago
|
package wechatopen
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
2 years ago
|
"go.dtapp.net/library/gorequest"
|
||
2 years ago
|
"net/http"
|
||
|
)
|
||
|
|
||
|
type GetCallBackIpResponse struct {
|
||
|
IpList []string `json:"ip_list"`
|
||
|
}
|
||
|
|
||
|
type GetCallBackIpResult struct {
|
||
|
Result GetCallBackIpResponse // 结果
|
||
|
Body []byte // 内容
|
||
2 years ago
|
Http gorequest.Response // 请求
|
||
2 years ago
|
Err error // 错误
|
||
|
}
|
||
|
|
||
2 years ago
|
func NewGetCallBackIpResult(result GetCallBackIpResponse, body []byte, http gorequest.Response, err error) *GetCallBackIpResult {
|
||
|
return &GetCallBackIpResult{Result: result, Body: body, Http: http, Err: err}
|
||
2 years ago
|
}
|
||
|
|
||
|
// CgiBinGetApiDomainIp 获取微信服务器IP地址
|
||
|
// https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_the_WeChat_server_IP_address.html
|
||
|
func (app *App) CgiBinGetApiDomainIp(componentAccessToken string) *GetCallBackIpResult {
|
||
|
// 请求
|
||
2 years ago
|
request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/cgi-bin/get_api_domain_ip?access_token=%s", componentAccessToken), map[string]interface{}{}, http.MethodGet)
|
||
2 years ago
|
// 定义
|
||
|
var response GetCallBackIpResponse
|
||
2 years ago
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||
|
return NewGetCallBackIpResult(response, request.ResponseBody, request, err)
|
||
2 years ago
|
}
|