This commit is contained in:
邹宗楠
2023-01-30 14:45:04 +08:00
parent a67c57c92e
commit fac70ca58a
4 changed files with 73 additions and 10 deletions

View File

@@ -1,9 +1,9 @@
package kuaishou_mini
import (
"encoding/json"
"fmt"
"git.rosy.net.cn/baseapi/platformapi"
"git.rosy.net.cn/baseapi/utils"
"net/http"
"strings"
"sync"
@@ -14,7 +14,7 @@ const (
KuaiShouBashUrl = "https://open.kuaishou.com" // 域名
// 获取授权信息
KuaiShouAuthLogin = "oauth2/mp/code2session" // 授权登录
KuaiShouAuthLogin = KuaiShouBashUrl + "/oauth2/mp/code2session" // 授权登录
)
type API struct {
@@ -51,14 +51,11 @@ func New(appSecret, appId string, config ...*platformapi.APIConfig) *API {
// AccessAPI2 发送请求
func (a *API) AccessAPI2(url string, params map[string]interface{}) (retVal map[string]interface{}, err error) {
data, err := json.Marshal(params)
if err != nil {
return nil, err
}
err = platformapi.AccessPlatformAPIWithRetry(a.client,
func() *http.Request {
request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(string(data)))
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(utils.Map2URLValues(params).Encode()))
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
return request
},
a.config,