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/meituan/mini_code.go

42 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package meituan
import (
"encoding/json"
"net/http"
)
type MiniCodeResponse struct {
Status int `json:"status"` // 状态值0为成功非0为异常
Des string `json:"des,omitempty"` // 异常描述信息
Data string `json:"data,omitempty"` // 小程序二维码图片地址
}
type MiniCodeResult struct {
Result MiniCodeResponse // 结果
Body []byte // 内容
Err error // 错误
}
func NewMiniCodeResult(result MiniCodeResponse, body []byte, err error) *MiniCodeResult {
return &MiniCodeResult{Result: result, Body: body, Err: err}
}
// MiniCode 小程序生成二维码(新版)
// https://union.meituan.com/v2/apiDetail?id=26
func (app *App) MiniCode(actId int64, sid string) *MiniCodeResult {
// 参数
param := NewParams()
param.Set("appkey", app.AppKey)
param.Set("sid", sid)
param.Set("actId", actId)
// 转换
params := app.NewParamsWith(param)
params["sign"] = app.getSign(app.Secret, params)
// 请求
body, err := app.request("https://openapi.meituan.com/api/miniCode", params, http.MethodGet)
// 定义
var response MiniCodeResponse
err = json.Unmarshal(body, &response)
return NewMiniCodeResult(response, body, err)
}