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.
41 lines
1.3 KiB
41 lines
1.3 KiB
2 years ago
|
package wechatopen
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
2 years ago
|
"go.dtapp.net/library/gorequest"
|
||
2 years ago
|
"net/http"
|
||
|
)
|
||
|
|
||
|
type WxaGetQrcodeResponse struct {
|
||
|
Errcode int `json:"errcode"`
|
||
|
Errmsg string `json:"errmsg"`
|
||
|
}
|
||
|
|
||
|
type WxaGetQrcodeResult struct {
|
||
|
Result WxaGetQrcodeResponse // 结果
|
||
|
Body []byte // 内容
|
||
2 years ago
|
Http gorequest.Response // 请求
|
||
2 years ago
|
Err error // 错误
|
||
|
}
|
||
|
|
||
2 years ago
|
func NewWxaGetQrcodeResult(result WxaGetQrcodeResponse, body []byte, http gorequest.Response, err error) *WxaGetQrcodeResult {
|
||
|
return &WxaGetQrcodeResult{Result: result, Body: body, Http: http, Err: err}
|
||
2 years ago
|
}
|
||
|
|
||
|
// WxaGetQrcode 获取体验版二维码
|
||
|
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_qrcode.html
|
||
|
func (app *App) WxaGetQrcode(path string) *WxaGetQrcodeResult {
|
||
|
// 参数
|
||
|
params := NewParams()
|
||
|
if path != "" {
|
||
|
params["path"] = path // 指定二维码扫码后直接进入指定页面并可同时带上参数)
|
||
|
}
|
||
|
// 请求
|
||
2 years ago
|
request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/get_qrcode?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodGet)
|
||
2 years ago
|
// 定义
|
||
|
var response WxaGetQrcodeResponse
|
||
2 years ago
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||
|
return NewWxaGetQrcodeResult(response, request.ResponseBody, request, err)
|
||
2 years ago
|
}
|