聚水潭上传微信小店相关逻辑

This commit is contained in:
wule committed 2026-01-29 20:54:17 +08:00
1 parent 625f4d9420
commit b4fa5cacb1
26 files changed
+2570 -487

No files matched your search

@@ -99,6 +99,66 @@ namespace KJD_Web.Utils
return result;
}
public static string e57PostResponse(string _url, string _data, string referer)
{
HttpWebResponse response = null;
string result;
try
{
string url = _url;
HttpWebRequest request;
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol =
ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
request = WebRequest.Create(url) as HttpWebRequest;
request.ProtocolVersion = HttpVersion.Version10;
}
else
request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = true;
request.Headers.Set(HttpRequestHeader.CacheControl, "max-age=0");
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36";
request.ContentType = "application/json";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"; //request.Accept = "*/*";
request.Referer = referer;
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
request.Method = "POST";
request.ServicePoint.Expect100Continue = false;
string body = _data;
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
request.ContentLength = postBytes.Length;
Stream stream = request.GetRequestStream();
stream.Write(postBytes, 0, postBytes.Length);
stream.Close();
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
response = (HttpWebResponse)ex.Response;
result = ReadResponse(response);
return result;
}
else return ex.Message;
}
catch (Exception e)
{
if (response != null) response.Close();
return e.Message;
}
result = ReadResponse(response);
return result;
}
public static string e57GetResponse(string _url, string referer)
{
HttpWebResponse response = null;