pdd推广商品
This commit is contained in:
@@ -206,15 +206,43 @@ func (a *API) ResourceURLGen(pid string, resourceType int) (resourceURLGenResult
|
|||||||
return resourceURLGenResult, err
|
return resourceURLGenResult, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GoodsPromotionURLGenResult struct {
|
||||||
|
MobileURL string `json:"mobile_url"`
|
||||||
|
WeAppInfo struct {
|
||||||
|
WeAppIconURL string `json:"we_app_icon_url"`
|
||||||
|
UserName string `json:"user_name"`
|
||||||
|
PagePath string `json:"page_path"`
|
||||||
|
SourceDisplayName string `json:"source_display_name"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
AppID string `json:"app_id"`
|
||||||
|
Desc string `json:"desc"`
|
||||||
|
} `json:"we_app_info"`
|
||||||
|
MobileShortURL string `json:"mobile_short_url"`
|
||||||
|
WeAppWebViewURL string `json:"we_app_web_view_url"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
ShortURL string `json:"short_url"`
|
||||||
|
WeAppWebViewShortURL string `json:"we_app_web_view_short_url"`
|
||||||
|
}
|
||||||
|
|
||||||
//生成商品推广链接
|
//生成商品推广链接
|
||||||
func (a *API) GoodsPromotionURLGen(pid string, goodsID string) (resourceURLGenResult *ResourceURLGenResult, err error) {
|
func (a *API) GoodsPromotionURLGen(pid string, goodsID string, isAuth bool) (resourceURLGenResult *GoodsPromotionURLGenResult, err error) {
|
||||||
result, err := a.AccessAPI("pdd.ddk.goods.promotion.url.generate", false, map[string]interface{}{
|
var resourceURLGenResults []*GoodsPromotionURLGenResult
|
||||||
"p_id": pid,
|
params := map[string]interface{}{
|
||||||
//"generate_short_url": true,
|
"p_id": pid,
|
||||||
"goods_sign_list": []string{"\"" + goodsID + "\""},
|
"generate_short_url": true,
|
||||||
})
|
"goods_sign_list": []string{"\"" + goodsID + "\""},
|
||||||
|
//"generate_authority_url": true,
|
||||||
|
"generate_we_app": true,
|
||||||
|
}
|
||||||
|
if isAuth {
|
||||||
|
params["generate_authority_url"] = true
|
||||||
|
}
|
||||||
|
result, err := a.AccessAPI("pdd.ddk.goods.promotion.url.generate", false, params)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
utils.Map2StructByJson(result["resource_url_response"], &resourceURLGenResult, false)
|
utils.Map2StructByJson(result["goods_promotion_url_generate_response"].(map[string]interface{})["goods_promotion_url_list"], &resourceURLGenResults, false)
|
||||||
|
if len(resourceURLGenResults) > 0 {
|
||||||
|
return resourceURLGenResults[0], err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return resourceURLGenResult, err
|
return resourceURLGenResult, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func TestResourceURLGen(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGoodsPromotionURLGen(t *testing.T) {
|
func TestGoodsPromotionURLGen(t *testing.T) {
|
||||||
result, err := api.GoodsPromotionURLGen("14501219_204919171", "Y9j2gIZ_GQ1KWDjRwfbZd9rMFl_x9NJ4_JQmOjnZyb5")
|
result, err := api.GoodsPromotionURLGen("14501219_204919171", "Y9j2gIZ_GQ1KWDjRwfbZd9rMFl_x9NJ4_JQmOjnZyb5", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user