瀏覽代碼

拼多多联盟

master
huangjiajun 7 月之前
父節點
當前提交
b5a5e23437
共有 4 個文件被更改,包括 388 次插入0 次删除
  1. +177
    -0
      md/cps_pdd/extend_url.go
  2. +34
    -0
      pdd_union/api.go
  3. +171
    -0
      pdd_union/extend_url.go
  4. +6
    -0
      pdd_union/pid.go

+ 177
- 0
md/cps_pdd/extend_url.go 查看文件

@@ -0,0 +1,177 @@
package cps_pdd

type ExtendUrl struct {
GoodsPromotionUrlGenerateResponse struct {
GoodsPromotionUrlList []struct {
MobileShortUrl string `json:"mobile_short_url"`
MobileUrl string `json:"mobile_url"`
QqAppInfo struct {
AppId string `json:"app_id"`
BannerUrl string `json:"banner_url"`
Desc string `json:"desc"`
PagePath string `json:"page_path"`
QqAppIconUrl string `json:"qq_app_icon_url"`
SourceDisplayName string `json:"source_display_name"`
Title string `json:"title"`
UserName string `json:"user_name"`
} `json:"qq_app_info"`
SchemaUrl string `json:"schema_url"`
ShortUrl string `json:"short_url"`
TzSchemaUrl string `json:"tz_schema_url"`
Url string `json:"url"`
WeAppInfo struct {
AppId string `json:"app_id"`
BannerUrl string `json:"banner_url"`
Desc string `json:"desc"`
PagePath string `json:"page_path"`
SourceDisplayName string `json:"source_display_name"`
Title string `json:"title"`
UserName string `json:"user_name"`
WeAppIconUrl string `json:"we_app_icon_url"`
} `json:"we_app_info"`
} `json:"goods_promotion_url_list"`
} `json:"goods_promotion_url_generate_response"`
}

type MainThemeUrl struct {
ResourceUrlResponse struct {
MultiUrlList struct {
ShortUrl string `json:"short_url"`
Url string `json:"url"`
} `json:"multi_url_list"`
Sign string `json:"sign"`
SingleUrlList struct {
MobileShortUrl string `json:"mobile_short_url"`
MobileUrl string `json:"mobile_url"`
SchemaUrl string `json:"schema_url"`
ShortUrl string `json:"short_url"`
TzSchemaUrl string `json:"tz_schema_url"`
Url string `json:"url"`
WeAppPagePath string `json:"we_app_page_path"`
WeAppInfo struct {
AppId string `json:"app_id"`
BannerUrl string `json:"banner_url"`
Desc string `json:"desc"`
PagePath string `json:"page_path"`
SourceDisplayName string `json:"source_display_name"`
Title string `json:"title"`
UserName string `json:"user_name"`
WeAppIconUrl string `json:"we_app_icon_url"`
} `json:"we_app_info"`
} `json:"single_url_list"`
WeAppInfo struct {
AppId string `json:"app_id"`
BannerUrl string `json:"banner_url"`
Desc string `json:"desc"`
PagePath string `json:"page_path"`
SourceDisplayName string `json:"source_display_name"`
Title string `json:"title"`
UserName string `json:"user_name"`
WeAppIconUrl string `json:"we_app_icon_url"`
} `json:"we_app_info"`
} `json:"resource_url_response"`
}

type WnMainThemeUrl struct {
GoodsZsUnitGenerateResponse struct {
MobileShortUrl string `json:"mobile_short_url"`
MobileUrl string `json:"mobile_url"`
SchemaUrl string `json:"schema_url"`
ShortUrl string `json:"short_url"`
TzSchemaUrl string `json:"tz_schema_url"`
Url string `json:"url"`
WeAppPagePath string `json:"we_app_page_path"`
WeAppInfo struct {
AppId string `json:"app_id"`
BannerUrl string `json:"banner_url"`
Desc string `json:"desc"`
PagePath string `json:"page_path"`
SourceDisplayName string `json:"source_display_name"`
Title string `json:"title"`
UserName string `json:"user_name"`
WeAppIconUrl string `json:"we_app_icon_url"`
} `json:"we_app_info"`
} `json:"goods_zs_unit_generate_response"`
}
type RpUrl struct {
RpPromotionUrlGenerateResponse struct {
ResourceList []struct {
Desc string `json:"desc"`
Url string `json:"url"`
} `json:"resource_list"`
UrlList []struct {
MobileShortUrl string `json:"mobile_short_url"`
MobileUrl string `json:"mobile_url"`
MultiGroupMobileShortUrl string `json:"multi_group_mobile_short_url"`
MultiGroupMobileUrl string `json:"multi_group_mobile_url"`
MultiGroupShortUrl string `json:"multi_group_short_url"`
MultiGroupUrl string `json:"multi_group_url"`
QqAppInfo struct {
AppId string `json:"app_id"`
BannerUrl string `json:"banner_url"`
Desc string `json:"desc"`
PagePath string `json:"page_path"`
QqAppIconUrl string `json:"qq_app_icon_url"`
SourceDisplayName string `json:"source_display_name"`
Title string `json:"title"`
UserName string `json:"user_name"`
} `json:"qq_app_info"`
SchemaUrl string `json:"schema_url"`
ShortUrl string `json:"short_url"`
TzSchemaUrl string `json:"tz_schema_url"`
Url string `json:"url"`
WeAppInfo struct {
AppId string `json:"app_id"`
BannerUrl string `json:"banner_url"`
Desc string `json:"desc"`
PagePath string `json:"page_path"`
SourceDisplayName string `json:"source_display_name"`
Title string `json:"title"`
UserName string `json:"user_name"`
WeAppIconUrl string `json:"we_app_icon_url"`
} `json:"we_app_info"`
WeixinShortLink string `json:"weixin_short_link"`
} `json:"url_list"`
} `json:"rp_promotion_url_generate_response"`
}
type PromUrl struct {
CmsPromotionUrlGenerateResponse struct {
ResourceList []struct {
Desc string `json:"desc"`
Url string `json:"url"`
} `json:"resource_list"`
UrlList []struct {
MobileShortUrl string `json:"mobile_short_url"`
MobileUrl string `json:"mobile_url"`
MultiGroupMobileShortUrl string `json:"multi_group_mobile_short_url"`
MultiGroupMobileUrl string `json:"multi_group_mobile_url"`
MultiGroupShortUrl string `json:"multi_group_short_url"`
MultiGroupUrl string `json:"multi_group_url"`
QqAppInfo struct {
AppId string `json:"app_id"`
BannerUrl string `json:"banner_url"`
Desc string `json:"desc"`
PagePath string `json:"page_path"`
QqAppIconUrl string `json:"qq_app_icon_url"`
SourceDisplayName string `json:"source_display_name"`
Title string `json:"title"`
UserName string `json:"user_name"`
} `json:"qq_app_info"`
SchemaUrl string `json:"schema_url"`
ShortUrl string `json:"short_url"`
TzSchemaUrl string `json:"tz_schema_url"`
Url string `json:"url"`
WeAppInfo struct {
AppId string `json:"app_id"`
BannerUrl string `json:"banner_url"`
Desc string `json:"desc"`
PagePath string `json:"page_path"`
SourceDisplayName string `json:"source_display_name"`
Title string `json:"title"`
UserName string `json:"user_name"`
WeAppIconUrl string `json:"we_app_icon_url"`
} `json:"we_app_info"`
WeixinShortLink string `json:"weixin_short_link"`
} `json:"url_list"`
} `json:"cms_promotion_url_generate_response"`
}

+ 34
- 0
pdd_union/api.go 查看文件

@@ -1 +1,35 @@
package pdd_union

import (
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"github.com/syyongx/php2go"
"sort"
"strings"
"time"
)

func Send(keyArr map[string]string, method string, param map[string]interface{}) (string, error) {
param["client_id"] = keyArr["app_key"]
param["type"] = method
param["data_type"] = "JSON"
param["timestamp"] = time.Now().Unix() * 1000
// 获取Key
var keys []string
for k := range param {
keys = append(keys, k)
}
// 排序asc
sort.Strings(keys)
str := ""
for _, v := range keys {
if param[v] == "" {
continue
}
str += v + zhios_third_party_utils.AnyToString(param[v])
}
param["sign"] = strings.ToUpper(php2go.Md5(keyArr["app_secret"] + str + keyArr["app_secret"]))

url := "http://gw-api.pinduoduo.com/api/router"
post, err := zhios_third_party_utils.CurlPost(url, param, nil)
return string(post), err
}

+ 171
- 0
pdd_union/extend_url.go 查看文件

@@ -0,0 +1,171 @@
package pdd_union

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/cps_pdd"
"encoding/json"
)

//https://open.pinduoduo.com/application/document/api?id=pdd.ddk.oauth.goods.prom.url.generate
func ExtendUrl(keyArr map[string]string, param map[string]interface{}) map[string]string {
send, _ := Send(keyArr, "pdd.ddk.oauth.goods.prom.url.generate", param)
var res cps_pdd.ExtendUrl
json.Unmarshal([]byte(send), &res)
tmp := map[string]string{
"url": "",
"open_app_url": "",
"no_open_app_url": "",
"page_path": "",
"schema_url": "",
}
for _, v := range res.GoodsPromotionUrlGenerateResponse.GoodsPromotionUrlList {
tmp["url"] = v.ShortUrl
tmp["open_app_url"] = v.MobileUrl
tmp["no_open_app_url"] = v.ShortUrl
tmp["page_path"] = v.WeAppInfo.PagePath
tmp["schema_url"] = v.SchemaUrl
if param["open_app"] == "" && param["link_type"] != "" {
tmp["url"] = v.Url
}
if param["open_app"] != "" {
tmp["url"] = v.MobileShortUrl
}
if param["open_app"] != "" && param["link_type"] != "" {
tmp["url"] = v.MobileUrl
}
}
return tmp
}

//https://open.pinduoduo.com/application/document/api?id=pdd.ddk.oauth.resource.url.gen
func MainThemeUrl(keyArr map[string]string, param map[string]interface{}) map[string]string {
send, _ := Send(keyArr, "pdd.ddk.oauth.resource.url.gen", param)
var res cps_pdd.MainThemeUrl
json.Unmarshal([]byte(send), &res)
tmp := map[string]string{
"url": "",
"open_app_url": "",
"no_open_app_url": "",
"page_path": "",
"schema_url": "",
}
tmp["url"] = res.ResourceUrlResponse.SingleUrlList.ShortUrl
tmp["open_app_url"] = res.ResourceUrlResponse.SingleUrlList.MobileUrl
tmp["no_open_app_url"] = res.ResourceUrlResponse.SingleUrlList.ShortUrl
tmp["page_path"] = res.ResourceUrlResponse.WeAppInfo.PagePath
tmp["schema_url"] = res.ResourceUrlResponse.SingleUrlList.SchemaUrl
if param["open_app"] == "" && param["link_type"] != "" {
tmp["url"] = res.ResourceUrlResponse.SingleUrlList.Url
}
if param["open_app"] != "" {
tmp["url"] = res.ResourceUrlResponse.SingleUrlList.MobileShortUrl
}
if param["open_app"] != "" && param["link_type"] != "" {
tmp["url"] = res.ResourceUrlResponse.SingleUrlList.MobileUrl
}
if res.ResourceUrlResponse.SingleUrlList.WeAppInfo.PagePath == "" {
tmp["page_path"] = res.ResourceUrlResponse.SingleUrlList.WeAppPagePath
}
return tmp
}

//https://open.pinduoduo.com/application/document/api?id=pdd.ddk.oauth.goods.zs.unit.url.gen
func WnMainThemeUrl(keyArr map[string]string, param map[string]interface{}) map[string]string {
send, _ := Send(keyArr, "pdd.ddk.oauth.goods.zs.unit.url.gen", param)
var res cps_pdd.WnMainThemeUrl
json.Unmarshal([]byte(send), &res)
tmp := map[string]string{
"url": "",
"open_app_url": "",
"no_open_app_url": "",
"page_path": "",
"schema_url": "",
}
tmp["url"] = res.GoodsZsUnitGenerateResponse.ShortUrl
tmp["open_app_url"] = res.GoodsZsUnitGenerateResponse.MobileUrl
tmp["no_open_app_url"] = res.GoodsZsUnitGenerateResponse.ShortUrl
tmp["page_path"] = res.GoodsZsUnitGenerateResponse.WeAppInfo.PagePath
tmp["schema_url"] = res.GoodsZsUnitGenerateResponse.SchemaUrl
if param["open_app"] == "" && param["link_type"] != "" {
tmp["url"] = res.GoodsZsUnitGenerateResponse.Url
}
if param["open_app"] != "" {
tmp["url"] = res.GoodsZsUnitGenerateResponse.MobileShortUrl
}
if param["open_app"] != "" && param["link_type"] != "" {
tmp["url"] = res.GoodsZsUnitGenerateResponse.MobileUrl
}
if res.GoodsZsUnitGenerateResponse.WeAppInfo.PagePath == "" {
tmp["page_path"] = res.GoodsZsUnitGenerateResponse.WeAppPagePath
}
return tmp
}

//https://open.pinduoduo.com/application/document/api?id=pdd.ddk.oauth.rp.prom.url.generate
func RpUrl(keyArr map[string]string, param map[string]interface{}) map[string]string {
send, _ := Send(keyArr, "pdd.ddk.oauth.rp.prom.url.generate", param)
var res cps_pdd.RpUrl
json.Unmarshal([]byte(send), &res)
tmp := map[string]string{
"url": "",
"open_app_url": "",
"no_open_app_url": "",
"page_path": "",
"schema_url": "",
"user_name": "",
"app_id": "",
}
for _, v := range res.RpPromotionUrlGenerateResponse.UrlList {
tmp["url"] = v.ShortUrl
tmp["open_app_url"] = v.MobileUrl
tmp["no_open_app_url"] = v.ShortUrl
tmp["page_path"] = v.WeAppInfo.PagePath
tmp["user_name"] = v.WeAppInfo.UserName
tmp["app_id"] = v.WeAppInfo.AppId
tmp["schema_url"] = v.SchemaUrl
if param["open_app"] == "" && param["link_type"] != "" {
tmp["url"] = v.Url
}
if param["open_app"] != "" {
tmp["url"] = v.MobileShortUrl
}
if param["open_app"] != "" && param["link_type"] != "" {
tmp["url"] = v.MobileUrl
}
}
return tmp
}

//https://open.pinduoduo.com/application/document/api?id=pdd.ddk.oauth.cms.prom.url.generate
func PromUrl(keyArr map[string]string, param map[string]interface{}) map[string]string {
send, _ := Send(keyArr, "pdd.ddk.oauth.cms.prom.url.generate", param)
var res cps_pdd.PromUrl
json.Unmarshal([]byte(send), &res)
tmp := map[string]string{
"url": "",
"open_app_url": "",
"no_open_app_url": "",
"page_path": "",
"schema_url": "",
"user_name": "",
"app_id": "",
}
for _, v := range res.CmsPromotionUrlGenerateResponse.UrlList {
tmp["url"] = v.ShortUrl
tmp["open_app_url"] = v.MobileUrl
tmp["no_open_app_url"] = v.ShortUrl
tmp["page_path"] = v.WeAppInfo.PagePath
tmp["user_name"] = v.WeAppInfo.UserName
tmp["app_id"] = v.WeAppInfo.AppId
tmp["schema_url"] = v.SchemaUrl
if param["open_app"] == "" && param["link_type"] != "" {
tmp["url"] = v.Url
}
if param["open_app"] != "" {
tmp["url"] = v.MobileShortUrl
}
if param["open_app"] != "" && param["link_type"] != "" {
tmp["url"] = v.MobileUrl
}
}
return tmp
}

+ 6
- 0
pdd_union/pid.go 查看文件

@@ -0,0 +1,6 @@
package pdd_union

func CreatePid(keyArr map[string]string, param map[string]interface{}) (string, error) {
send, err := Send(keyArr, "", param)
return send, err
}

Loading…
取消
儲存