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/wechatoffice/debug.cgi-bin.ticket.check.go

35 lines
1.1 KiB

package wechatoffice
import (
"encoding/json"
"fmt"
"net/http"
)
type DebugCgiBinTicketCheckResponse struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
}
type DebugCgiBinTicketCheckResult struct {
Result DebugCgiBinTicketCheckResponse // 结果
Body []byte // 内容
Err error // 错误
}
func NewDebugCgiBinTicketCheckResult(result DebugCgiBinTicketCheckResponse, body []byte, err error) *DebugCgiBinTicketCheckResult {
return &DebugCgiBinTicketCheckResult{Result: result, Body: body, Err: err}
}
// DebugCgiBinTicketCheck 判断ticket是否合法
// https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=jsapisign
func (app *App) DebugCgiBinTicketCheck() *DebugCgiBinTicketCheckResult {
app.JsapiTicket = app.GetJsapiTicket()
// 请求
body, err := app.request(fmt.Sprintf("https://mp.weixin.qq.com/debug/cgi-bin/ticket/check?ticket=%s", app.JsapiTicket), map[string]interface{}{}, http.MethodGet)
// 定义
var response DebugCgiBinTicketCheckResponse
err = json.Unmarshal(body, &response)
return NewDebugCgiBinTicketCheckResult(response, body, err)
}