抖音二维码
This commit is contained in:
@@ -46,7 +46,7 @@ func (a *API) RefundOrderTT(param *RefundOrderReq) (string, error) {
|
||||
func (a *API) QueryRefundMsg() (map[string]interface{}, error) {
|
||||
param := map[string]interface{}{"app_id": a.GetAppID(), "out_refund_no": "7105943473253206285"}
|
||||
param["sign"] = a.Sign(param)
|
||||
data, err := a.AccessAPI2("https://developer.toutiao.com/api/apps/ecpay/v1/query_refund", param)
|
||||
data, err := a.AccessAPI2(QueryRefundUrl, param)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@ import (
|
||||
func (a *API) Sign(paramsMap map[string]interface{}) string {
|
||||
var paramsArr []string
|
||||
for k, v := range paramsMap {
|
||||
fmt.Println(k)
|
||||
fmt.Println(v)
|
||||
if k == "other_settle_params" || k == "app_id" || k == "sign" || k == "thirdparty_id " {
|
||||
continue
|
||||
}
|
||||
@@ -63,7 +61,7 @@ func (a *API) GetTiktokToken() error {
|
||||
tokenReq["appid"] = a.GetAppID()
|
||||
tokenReq["secret"] = a.GetSecret()
|
||||
tokenReq["grant_type"] = "client_credential"
|
||||
result, err := a.AccessAPI2("https://developer.toutiao.com/api/apps/v2/token", tokenReq)
|
||||
result, err := a.AccessAPI2(GetTiktokToken, tokenReq)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package tiktok
|
||||
|
||||
const (
|
||||
PayUrl = "https://developer.toutiao.com/api/apps/ecpay/v1/create_order"
|
||||
RefundUrl = "https://developer.toutiao.com/api/apps/ecpay/v1/create_refund"
|
||||
PayUrl = "https://developer.toutiao.com/api/apps/ecpay/v1/create_order" // 抖音下支付单
|
||||
RefundUrl = "https://developer.toutiao.com/api/apps/ecpay/v1/create_refund" // 申请退款
|
||||
QueryRefundUrl = "https://developer.toutiao.com/api/apps/ecpay/v1/query_refund" // 查询申请退款记录
|
||||
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" // 获取小程序二维码
|
||||
)
|
||||
|
||||
// OauthAccessTokenResData access_token
|
||||
|
||||
47
platformapi/tiktok/tiktok_qr_code.go
Normal file
47
platformapi/tiktok/tiktok_qr_code.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package tiktok
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
// 获取抖音小程序二维码
|
||||
func (a *API) GetTiktokQrCode() error {
|
||||
param := &QrCode{
|
||||
AppName: "douyin",
|
||||
AccessToken: "",
|
||||
Path: "pages/index/index",
|
||||
Width: 0,
|
||||
LineColor: nil,
|
||||
Background: nil,
|
||||
SetIcon: true,
|
||||
}
|
||||
a.CheckTokenIsExist()
|
||||
param.AccessToken = a.msgToken
|
||||
qrCode, err := a.AccessAPI2(GetTiktokQrCode, utils.Struct2MapByJson(param))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("qrcode", qrCode)
|
||||
return 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"`
|
||||
}
|
||||
@@ -94,3 +94,10 @@ func TestSQRefund(t *testing.T) {
|
||||
fmt.Println(aa)
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
func TestQrCode(t *testing.T) {
|
||||
a := New("5c08a0465cf0f996af254a03b6c2548defef87ad ", "tta6a1d01c399f264201")
|
||||
|
||||
err := a.GetTiktokQrCode()
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ func (a *API) GetTiktokOauth(code string) (*TiktokOauthResone, error) {
|
||||
tokenReq["code"] = code
|
||||
tokenReq["secret"] = a.GetSecret()
|
||||
tokenReq["anonymous_code"] = ""
|
||||
result, err := a.AccessAPI2("https://developer.toutiao.com/api/apps/v2/jscode2session", tokenReq)
|
||||
result, err := a.AccessAPI2(GetTiktokOauth, tokenReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user