Files
baseapi/platformapi/tiktok/tiktok_qr_code.go
2022-06-09 14:13:31 +08:00

48 lines
1.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package tiktok
import (
"git.rosy.net.cn/baseapi/utils"
)
// GetTiktokQrCode 获取抖音小程序二维码
func (a *API) GetTiktokQrCode(storeId string) (map[string]interface{}, error) {
param := &QrCode{
AppName: "douyin",
AccessToken: "",
Path: "pages/index/index?" + storeId,
Width: 0,
LineColor: nil,
Background: nil,
SetIcon: true,
}
if err := a.CheckTokenIsExist(); err != nil {
return nil, err
}
param.AccessToken = a.msgToken
qrCode, err := a.AccessAPI2(GetTiktokQrCode, utils.Struct2MapByJson(param))
if err != nil {
return nil, err
}
return qrCode, err
}
//type QrCodeRes struct {
// ErrCode int64 `json:"errcode"`
// ErrCode int64 `json:"errcode"`
//}
type QrCode struct {
AppName string `json:"appname"` // 是打开二维码的字节系 app 名称,默认为今日头条,取值如下表所示
AccessToken string `json:"access_token"` // 服务端 API 调用标识,获取方法
Path string `json:"path"` // 小程序/小游戏启动参数,小程序则格式为 encode({path}?{query})
Width int `json:"width"` // 二维码宽度
LineColor *LineColor `json:"line_color"` // 二维码线条颜色
Background *LineColor `json:"background"` // 二维码背景颜色
SetIcon bool `json:"set_icon"` // 是否展示小程序/小游戏 icon
}
type LineColor struct {
R int `json:"r"`
G int `json:"g"`
B int `json:"b"`
}