This commit is contained in:
richboo111
2022-08-18 16:36:11 +08:00
parent 75679bf4d1
commit 8b6fe6e92b
3 changed files with 5 additions and 2 deletions

View File

@@ -36,7 +36,7 @@ func (a *API) AccessAPI2(url string, params map[string]interface{}) (retVal map[
}
err = platformapi.AccessPlatformAPIWithRetry(a.client,
func() *http.Request {
request, _ := http.NewRequest(http.MethodGet, url, strings.NewReader(string(data)))
request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(string(data)))
request.Header.Set("Content-Type", "application/json")
return request
},

View File

@@ -35,7 +35,7 @@ func TestCode2(t *testing.T) {
func TestCode343(t *testing.T) {
a := New("5c8492ec2744fb72bb6cc356983f3cfc317f85d4", "ttaceeda5333d7a7ab01")
data, err := a.GetTiktokOauth("0G3WBJXM4kuYlM0UmbRsrg9Bx_7YOQJflKewL6F7qe5aQDoy9j2mxgigESyPMlXzPNnvYsn1Swix-3pabUfqS-_2_H3WzOI6aeU_bSW10LzA-gq-8j797BU4iL0")
data, err := a.GetTiktokOauth("ghUxJ6g1xQbW6_rfnoTRlHUnWZ2THaPXJuxekaQ0-kz_5gw-94onRi982egQshVtaS3Nl5tLj929_1BVBmO3hm0JHJqdj9MDUloLSBBXSn-j0sX0DA6JPOyCaFM&ttaceeda5333d7a7ab01")
fmt.Println(err)
fmt.Println(data)
}

View File

@@ -3,15 +3,18 @@ package tiktok
import (
"errors"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
)
// 获取抖音登录授权2
func (a *API) GetTiktokOauth(code string) (*TiktokOauthResone, error) {
globals.SugarLogger.Debug("初始code=============", code)
tokenReq := make(map[string]interface{}, 3)
tokenReq["appid"] = a.GetAppID()
tokenReq["code"] = code
tokenReq["secret"] = a.GetSecret()
tokenReq["anonymous_code"] = ""
result, err := a.AccessAPI2(GetTiktokOauth, tokenReq)
if err != nil {
return nil, err