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