Documentation ¶
Overview ¶
Package util 开发辅助
Index ¶
- func CallbackCheck(ctx *offiaccount.OffiAccount, payload []byte) (resp []byte, err error)
- func ClearQuota(ctx *offiaccount.OffiAccount, payload []byte) (resp []byte, err error)
- func GetApiDomainIp(ctx *offiaccount.OffiAccount) (resp []byte, err error)
- func GetCallbackIp(ctx *offiaccount.OffiAccount) (resp []byte, err error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallbackCheck ¶
func CallbackCheck(ctx *offiaccount.OffiAccount, payload []byte) (resp []byte, err error)
网络检测
为了帮助开发者排查回调连接失败的问题,提供这个网络检测的API。它可以对开发者URL做域名解析,然后对所有IP进行一次ping操作,得到丢包率和耗时
See: https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Network_Detection.html
POST https://api.weixin.qq.com/cgi-bin/callback/check?access_token=ACCESS_TOKEN
Example ¶
package main import ( "fmt" "github.com/fastwego/offiaccount" "github.com/fastwego/offiaccount/apis/util" ) func main() { var ctx *offiaccount.OffiAccount payload := []byte("{}") resp, err := util.CallbackCheck(ctx, payload) fmt.Println(resp, err) }
Output:
func ClearQuota ¶
func ClearQuota(ctx *offiaccount.OffiAccount, payload []byte) (resp []byte, err error)
对公众号的所有api调用次数进行清零
See: https://developers.weixin.qq.com/doc/offiaccount/Message_Management/API_Call_Limits.html
POST https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN
Example ¶
package main import ( "fmt" "github.com/fastwego/offiaccount" "github.com/fastwego/offiaccount/apis/util" ) func main() { var ctx *offiaccount.OffiAccount payload := []byte("{}") resp, err := util.ClearQuota(ctx, payload) fmt.Println(resp, err) }
Output:
func GetApiDomainIp ¶
func GetApiDomainIp(ctx *offiaccount.OffiAccount) (resp []byte, err error)
获取微信API接口 IP地址
即api.weixin.qq.com的解析地址,由开发者调用微信侧的接入IP
GET https://api.weixin.qq.com/cgi-bin/get_api_domain_ip?access_token=ACCESS_TOKEN
Example ¶
package main import ( "fmt" "github.com/fastwego/offiaccount" "github.com/fastwego/offiaccount/apis/util" ) func main() { var ctx *offiaccount.OffiAccount resp, err := util.GetApiDomainIp(ctx) fmt.Println(resp, err) }
Output:
func GetCallbackIp ¶
func GetCallbackIp(ctx *offiaccount.OffiAccount) (resp []byte, err error)
获取微信服务器IP地址
如果公众号基于安全等考虑,需要获知微信服务器的IP地址列表,以便进行相关限制,可以通过该接口获得微信服务器IP地址列表或者IP网段信息
GET https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ACCESS_TOKEN
Example ¶
package main import ( "fmt" "github.com/fastwego/offiaccount" "github.com/fastwego/offiaccount/apis/util" ) func main() { var ctx *offiaccount.OffiAccount resp, err := util.GetCallbackIp(ctx) fmt.Println(resp, err) }
Output:
Types ¶
This section is empty.