添加抖音小程序二维码
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -58,9 +59,10 @@ func (a *API) CreateOrderByTicktock(param *TickTokCreateOrder) (string, string,
|
||||
// 获取抖音token
|
||||
func (a *API) GetTiktokToken() error {
|
||||
tokenReq := make(map[string]interface{}, 3)
|
||||
tokenReq["appid"] = a.GetAppID()
|
||||
tokenReq["secret"] = a.GetSecret()
|
||||
tokenReq["appid"] = TiktokAppId
|
||||
tokenReq["secret"] = TiktokSecret
|
||||
tokenReq["grant_type"] = "client_credential"
|
||||
globals.SugarLogger.Debug("=============", tokenReq)
|
||||
result, err := a.AccessAPI2(GetTiktokToken, tokenReq)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -7,6 +7,9 @@ const (
|
||||
GetTiktokToken = "https://developer.toutiao.com/api/apps/v2/token" // 查询申请退款记录
|
||||
GetTiktokOauth = "https://developer.toutiao.com/api/apps/v2/jscode2session" // 获取抖音授权
|
||||
GetTiktokQrCode = "https://developer.toutiao.com/api/apps/qrcode" // 获取小程序二维码
|
||||
|
||||
TiktokAppId = "tta6a1d01c399f264201"
|
||||
TiktokSecret = "5c08a0465cf0f996af254a03b6c2548defef87ad"
|
||||
)
|
||||
|
||||
// OauthAccessTokenResData access_token
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
package tiktok
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
// 获取抖音小程序二维码
|
||||
func (a *API) GetTiktokQrCode() error {
|
||||
// GetTiktokQrCode 获取抖音小程序二维码
|
||||
func (a *API) GetTiktokQrCode(storeId string) (map[string]interface{}, error) {
|
||||
param := &QrCode{
|
||||
AppName: "douyin",
|
||||
AccessToken: "",
|
||||
Path: "pages/index/index",
|
||||
Path: "pages/index/index?" + storeId,
|
||||
Width: 0,
|
||||
LineColor: nil,
|
||||
Background: nil,
|
||||
SetIcon: true,
|
||||
}
|
||||
a.CheckTokenIsExist()
|
||||
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 err
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println("qrcode", qrCode)
|
||||
return err
|
||||
return qrCode, err
|
||||
}
|
||||
|
||||
//type QrCodeRes struct {
|
||||
|
||||
@@ -96,8 +96,12 @@ func TestSQRefund(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestQrCode(t *testing.T) {
|
||||
a := New("5c08a0465cf0f996af254a03b6c2548defef87ad ", "tta6a1d01c399f264201")
|
||||
//a := New("5c08a0465cf0f996af254a03b6c2548defef87ad ", "tta6a1d01c399f264201")
|
||||
|
||||
err := a.GetTiktokQrCode()
|
||||
fmt.Println(err)
|
||||
//data, err := a.GetTiktokQrCode("storeID=668506")
|
||||
//fmt.Println("Err", err)
|
||||
//tiktokName := "tiktok" + utils.Int64ToStr(time.Now().Unix()) + ".jpg"
|
||||
//tiktokQrCode, err2 := jxutils.UploadExportContent([]byte(data["fakeData"].(string)), tiktokName)
|
||||
//fmt.Println(err2)
|
||||
//fmt.Println("tiktokQrCode", tiktokQrCode)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user