This commit is contained in:
邹宗楠
2022-05-30 18:41:39 +08:00
parent 60c6876da7
commit ad94f7579a
5 changed files with 144 additions and 33 deletions

View File

@@ -1,7 +1,6 @@
package tiktok
import (
"errors"
"git.rosy.net.cn/baseapi/utils"
)
@@ -42,31 +41,8 @@ type TiktokOauthResone struct {
}
}
// 获取抖音token
func (a *API) GetTiktokToken(code string) (*OauthAccessTokenRes, error) {
tokenReq := make(map[string]interface{}, 4)
tokenReq["client_secret"] = a.clientSecret
tokenReq["code"] = code
tokenReq["grant_type"] = "authorization_code"
tokenReq["client_key"] = a.clientKey
result, err := a.AccessAPI2(BaseURL, tokenReq)
if err != nil {
return nil, err
}
oauthAccessToken := &OauthAccessTokenRes{}
if err := utils.Map2StructByJson(result, oauthAccessToken, false); err != nil {
return nil, err
}
if oauthAccessToken.Data.ErrorCode != 0 {
return nil, errors.New(oauthAccessToken.Data.Description)
}
return oauthAccessToken, nil
}
// 获取抖音登录授权2
func (a *API) GetTiktokToken2(code string) (*TiktokOauthResone, error) {
func (a *API) GetTiktokOauth(code string) (*TiktokOauthResone, error) {
tokenReq := make(map[string]interface{}, 3)
tokenReq["appid"] = a.GetAppID()
tokenReq["code"] = code