tb
This commit is contained in:
@@ -108,3 +108,14 @@ func (a *API) ListActivitys() (listActivitysResult []*ListActivitysResult, err e
|
|||||||
}
|
}
|
||||||
return listActivitysResult, err
|
return listActivitysResult, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *API) UnionPromotion(PID string) (err error) {
|
||||||
|
_, err = a.AccessStorePage("https://api.m.jd.com/api", map[string]interface{}{
|
||||||
|
"functionId": "unionPromotion",
|
||||||
|
"appid": "u",
|
||||||
|
"_": time.Now().UnixNano(),
|
||||||
|
"loginType": 3,
|
||||||
|
"body": "{\"funName\":\"savePromotionSite\",\"param\":{\"siteId\":4100279071,\"spaceName\":" + PID + ",\"type\":3,\"unionType\":1}}",
|
||||||
|
}, false)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,3 +30,11 @@ func TestListActivitys(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUnionPromotion(t *testing.T) {
|
||||||
|
err := api.UnionPromotion("18160030913903")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
//t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,8 +2,40 @@ package tbunionapi
|
|||||||
|
|
||||||
import "git.rosy.net.cn/baseapi/utils"
|
import "git.rosy.net.cn/baseapi/utils"
|
||||||
|
|
||||||
|
type OptimusMaterialResult struct {
|
||||||
|
CategoryID int `json:"category_id"`
|
||||||
|
ClickURL string `json:"click_url"`
|
||||||
|
CommissionRate string `json:"commission_rate"`
|
||||||
|
CouponAmount int `json:"coupon_amount"`
|
||||||
|
CouponClickURL string `json:"coupon_click_url,omitempty"`
|
||||||
|
CouponEndTime string `json:"coupon_end_time"`
|
||||||
|
CouponRemainCount int `json:"coupon_remain_count"`
|
||||||
|
CouponShareURL string `json:"coupon_share_url,omitempty"`
|
||||||
|
CouponStartFee string `json:"coupon_start_fee"`
|
||||||
|
CouponStartTime string `json:"coupon_start_time"`
|
||||||
|
CouponTotalCount int `json:"coupon_total_count"`
|
||||||
|
ItemDescription string `json:"item_description"`
|
||||||
|
ItemID int64 `json:"item_id"`
|
||||||
|
JhsPriceUspList string `json:"jhs_price_usp_list"`
|
||||||
|
LevelOneCategoryID int `json:"level_one_category_id"`
|
||||||
|
LevelOneCategoryName string `json:"level_one_category_name"`
|
||||||
|
Nick string `json:"nick"`
|
||||||
|
PictURL string `json:"pict_url"`
|
||||||
|
ReservePrice string `json:"reserve_price"`
|
||||||
|
SellerID int64 `json:"seller_id"`
|
||||||
|
ShopTitle string `json:"shop_title"`
|
||||||
|
ShortTitle string `json:"short_title"`
|
||||||
|
SmallImages []string `json:"small_images,omitempty"`
|
||||||
|
SubTitle string `json:"sub_title"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
UserType int `json:"user_type"`
|
||||||
|
Volume int `json:"volume"`
|
||||||
|
WhiteImage string `json:"white_image"`
|
||||||
|
ZkFinalPrice string `json:"zk_final_price"`
|
||||||
|
}
|
||||||
|
|
||||||
//物料精选
|
//物料精选
|
||||||
func (a *API) OptimusMaterial(materialID, adzoneID, pageNo, pageSize int) (activityInfoGetResult *ActivityInfoGetResult, err error) {
|
func (a *API) OptimusMaterial(materialID, adzoneID, pageNo, pageSize int) (activityInfoGetResult []*OptimusMaterialResult, err error) {
|
||||||
result, err := a.AccessAPI("taobao.tbk.dg.optimus.material", false, map[string]interface{}{
|
result, err := a.AccessAPI("taobao.tbk.dg.optimus.material", false, map[string]interface{}{
|
||||||
"material_id": materialID,
|
"material_id": materialID,
|
||||||
"adzone_id": adzoneID,
|
"adzone_id": adzoneID,
|
||||||
@@ -11,7 +43,30 @@ func (a *API) OptimusMaterial(materialID, adzoneID, pageNo, pageSize int) (activ
|
|||||||
"page_size": pageSize,
|
"page_size": pageSize,
|
||||||
})
|
})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
utils.Map2StructByJson(result, &activityInfoGetResult, false)
|
utils.Map2StructByJson(result["result_list"], &activityInfoGetResult, false)
|
||||||
|
}
|
||||||
|
return activityInfoGetResult, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type MaterialOptionalParam struct {
|
||||||
|
AdzoneID int `json:"adzone_id,omitempty"`
|
||||||
|
Q string `json:"q,omitempty"`
|
||||||
|
ListID string `json:"list_id,omitempty"`
|
||||||
|
PageNo int `json:"page_no,omitempty"`
|
||||||
|
PageSize int `json:"page_size,omitempty"`
|
||||||
|
Sort int `json:"sort,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//物料搜索
|
||||||
|
func (a *API) MaterialOptional(materialID, adzoneID, pageNo, pageSize int) (activityInfoGetResult []*OptimusMaterialResult, err error) {
|
||||||
|
result, err := a.AccessAPI("taobao.tbk.dg.material.optional", false, map[string]interface{}{
|
||||||
|
"material_id": materialID,
|
||||||
|
"adzone_id": adzoneID,
|
||||||
|
"page_no": pageNo,
|
||||||
|
"page_size": pageSize,
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
utils.Map2StructByJson(result["result_list"], &activityInfoGetResult, false)
|
||||||
}
|
}
|
||||||
return activityInfoGetResult, err
|
return activityInfoGetResult, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestOptimusMaterial(t *testing.T) {
|
func TestOptimusMaterial(t *testing.T) {
|
||||||
result, err := api.OptimusMaterial(13366, 111339100149, 1, 20)
|
result, err := api.OptimusMaterial(28026, 111339100149, 1, 20)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
prodURL = "http://gw.api.taobao.com/router/rest"
|
prodURL = "https://gw.api.taobao.com/router/rest"
|
||||||
testURL = "http://gw.api.tbsandbox.com/router/rest"
|
testURL = "http://gw.api.tbsandbox.com/router/rest"
|
||||||
sigKey = "sign"
|
sigKey = "sign"
|
||||||
)
|
)
|
||||||
@@ -70,6 +70,7 @@ func (a *API) AccessAPI(action string, isPost bool, bizParams map[string]interfa
|
|||||||
params["timestamp"] = utils.Time2Str(time.Now())
|
params["timestamp"] = utils.Time2Str(time.Now())
|
||||||
params["v"] = "2.0"
|
params["v"] = "2.0"
|
||||||
params["format"] = "json"
|
params["format"] = "json"
|
||||||
|
params["simplify"] = true
|
||||||
params = utils.MergeMaps(params, bizParams)
|
params = utils.MergeMaps(params, bizParams)
|
||||||
signStr := a.signParam(params)
|
signStr := a.signParam(params)
|
||||||
params[sigKey] = signStr
|
params[sigKey] = signStr
|
||||||
|
|||||||
@@ -123,3 +123,30 @@ func (a *API) GatewayUnionpub() (gatewayUnionpubResult []*GatewayUnionpubResult,
|
|||||||
}
|
}
|
||||||
return gatewayUnionpubResult, err
|
return gatewayUnionpubResult, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//长链转短链
|
||||||
|
func (a *API) SpreadGet(url string) (result string, err error) {
|
||||||
|
data, err := a.AccessAPI("taobao.tbk.spread.get", false, map[string]interface{}{
|
||||||
|
"requests": "[{\"url\":\"" + url + "\"}]",
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
return data["results"].([]interface{})[0].(map[string]interface{})["content"].(string), err
|
||||||
|
}
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type TpwdCreateResult struct {
|
||||||
|
Model string `json:"model"`
|
||||||
|
PasswordSimple string `json:"password_simple"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//淘口令生成
|
||||||
|
func (a *API) TpwdCreate(url string) (tpwdCreateResult *TpwdCreateResult, err error) {
|
||||||
|
result, err := a.AccessAPI("taobao.tbk.tpwd.create", false, map[string]interface{}{
|
||||||
|
"url": url,
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
utils.Map2StructByJson(result["data"], &tpwdCreateResult, false)
|
||||||
|
}
|
||||||
|
return tpwdCreateResult, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,3 +52,19 @@ func TestGatewayUnionpub(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSpreadGet(t *testing.T) {
|
||||||
|
result, err := api.SpreadGet("https://s.click.taobao.com/t?e=m%3D2%26s%3D2gqN73exILFw4vFB6t2Z2ueEDrYVVa64Dne87AjQPk9yINtkUhsv0NoOB2fLPTMnkVwhSHgXrieh50lqdFqzEbW9xosplKRRRCvhzyw83VKVDvy6A0dAZeLisOrebtw4UyNpxLfgKr0jWpzpm6nEC0AG4SvB2excV3hN7ukc%2BfWwcfTMMtg5PxhC2gPyIPYTElgJOKaPvK1xKmPmpIKZsA%3D%3D&scm=1007.15348.115058.0_28026&pvid=a6cb6b60-9b39-4d8e-bcec-eef56cfeac8a&app_pvid=59590_33.8.141.241_825_1620441096797&ptl=floorId:28026;originalFloorId:28026;pvid:a6cb6b60-9b39-4d8e-bcec-eef56cfeac8a;app_pvid:59590_33.8.141.241_825_1620441096797&union_lens=lensId%3AMAPI%401620441096%40a6cb6b60-9b39-4d8e-bcec-eef56cfeac8a_591944957973%401")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTpwdCreate(t *testing.T) {
|
||||||
|
result, err := api.TpwdCreate("https://s.click.taobao.com/t?e=m%3D2%26s%3D2gqN73exILFw4vFB6t2Z2ueEDrYVVa64Dne87AjQPk9yINtkUhsv0NoOB2fLPTMnkVwhSHgXrieh50lqdFqzEbW9xosplKRRRCvhzyw83VKVDvy6A0dAZeLisOrebtw4UyNpxLfgKr0jWpzpm6nEC0AG4SvB2excV3hN7ukc%2BfWwcfTMMtg5PxhC2gPyIPYTElgJOKaPvK1xKmPmpIKZsA%3D%3D&scm=1007.15348.115058.0_28026&pvid=a6cb6b60-9b39-4d8e-bcec-eef56cfeac8a&app_pvid=59590_33.8.141.241_825_1620441096797&ptl=floorId:28026;originalFloorId:28026;pvid:a6cb6b60-9b39-4d8e-bcec-eef56cfeac8a;app_pvid:59590_33.8.141.241_825_1620441096797&union_lens=lensId%3AMAPI%401620441096%40a6cb6b60-9b39-4d8e-bcec-eef56cfeac8a_591944957973%401")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user