108 lines
3.3 KiB
C#
108 lines
3.3 KiB
C#
using AllBase;
|
|
using AllBase.Model.Result;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace TemuKJD.BLL.PddApi
|
|
{
|
|
public class PddApi
|
|
{
|
|
public Dictionary<string, object> Data { get; set; } = new Dictionary<string, object>();
|
|
|
|
public PddApi(ShopLoginInfo shop)
|
|
{
|
|
Data["access_token"] = shop.AccessToken;
|
|
}
|
|
|
|
public string PddGoodsAdd()
|
|
{
|
|
string type = "pdd.goods.add";
|
|
string html = PddApiRequest(type, Data);
|
|
return html;
|
|
}
|
|
|
|
public string PddGoodsDetailGet()
|
|
{
|
|
string type = "pdd.goods.detail.get";
|
|
string html = PddApiRequest(type, Data);
|
|
return html;
|
|
}
|
|
|
|
public string PddGoodsInformationUpdate()
|
|
{
|
|
string type = "pdd.goods.information.update";
|
|
string html = PddApiRequest(type, Data);
|
|
return html;
|
|
}
|
|
|
|
public string PddGoodsLogisticsTemplateGet()
|
|
{
|
|
string type = "pdd.goods.logistics.template.get";
|
|
string html = PddApiRequest(type, Data);
|
|
return html;
|
|
}
|
|
|
|
public string PddGoodsImageUpload()
|
|
{
|
|
string type = "pdd.goods.image.upload";
|
|
string html = PddApiRequest(type, Data);
|
|
return html;
|
|
}
|
|
|
|
public string PddGoodsSpecGet()
|
|
{
|
|
string type = "pdd.goods.spec.get";
|
|
string html = PddApiRequest(type, Data);
|
|
return html;
|
|
}
|
|
public string PddGoodsSpecIdGet()
|
|
{
|
|
string type = "pdd.goods.spec.id.get";
|
|
string html = PddApiRequest(type, Data);
|
|
return html;
|
|
}
|
|
|
|
public string PddGoodsCatRuleGet()
|
|
{
|
|
string type = "pdd.goods.cat.rule.get";
|
|
string html = PddApiRequest(type, Data);
|
|
return html;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="type">拼多多调用接口 pdd.*</param>
|
|
/// <param name="dict">拼多多接口入参</param>
|
|
/// <returns></returns>
|
|
static string PddApiRequest(string type, Dictionary<string,object> dict)
|
|
{
|
|
string clientId = "ad502ec19e0c49ab9df14f83494e153c";
|
|
string clientSecret = "bd52aba51737d03fc073711d386b3b0779d010ad";
|
|
|
|
if (string.IsNullOrEmpty(type))
|
|
return "{\"success\":false, \"error_msg\":\"调用接口不能为空\"}";
|
|
if (dict == null)
|
|
return "{\"success\":false, \"error_msg\":\"参数数组不能为空\"}";
|
|
|
|
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
|
var timeStamp = (long)(DateTime.Now - startTime).TotalMilliseconds;
|
|
|
|
dict["type"] = type;
|
|
dict["client_id"] = clientId;
|
|
dict["timestamp"] = timeStamp.ToString();
|
|
dict["data_type"] = "JSON";
|
|
|
|
var paramsDic = SignHelper.BuildSign(dict, clientSecret);
|
|
var jsonBody = JsonConvert.SerializeObject(paramsDic);
|
|
string result = GetHtml.PostUtf8("http://gw-api.pinduoduo.com/api/router", jsonBody, "application/json");
|
|
return result;
|
|
}
|
|
}
|
|
}
|