一、实现图片

C#  E店宝格格家接口对接-LMLPHP

二、实现通用方法

        /// <summary>
/// 调用通用方法
/// </summary>
/// <param name="strURL">调用地址+接口名称</param>
/// <param name="jsonParas">执行json字符串</param>
/// <param name="sign">sign</param>
/// <returns>json字符串,接口返回结果</returns>
public string Post(string strURL, string jsonParas, string sign)
{
//string strURL =methodName;
//创建一个HTTP请求
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
//Post请求方式
request.Method = "POST";
request.Headers.Add("sign", sign);
//内容类型
request.ContentType = "application/json;charset=utf-8";
//jsonParas = HttpUtility.UrlEncode(jsonParas);
string paraUrlCoded = jsonParas;
byte[] payload;
//将Json字符串转化为字节
payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
//设置请求的ContentLength
request.ContentLength = payload.Length;
//发送请求,获得请求流
Stream writer;
try
{
writer = request.GetRequestStream();//获取用于写入请求数据的Stream对象
}
catch (Exception)
{
writer = null;
Console.Write("连接服务器失败!");
}
//将请求参数写入流
writer.Write(payload, , payload.Length);
writer.Close();//关闭请求流
String strValue = "";//strValue为http响应所返回的字符流
HttpWebResponse response;
try
{
//获得响应流
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
response = ex.Response as HttpWebResponse;
}
Stream s = response.GetResponseStream();
StreamReader reader = new StreamReader(s);
strValue = reader.ReadToEnd();
return strValue;//返回Json数据
} /// <summary>
/// MD5签名方法
/// </summary>
/// <param name="inputText"></param>
/// <returns></returns>
public string MD5(string inputText)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] fromData = System.Text.Encoding.UTF8.GetBytes(inputText);
byte[] targetData = md5.ComputeHash(fromData);
string byte2String = null;
for (int i = ; i < targetData.Length; i++)
{
byte2String += targetData[i].ToString("x2");
}
return byte2String;
}

E店宝系统写入订单接口xml格式:

 StringBuilder sb = new StringBuilder();
sb.Append("<info>");
sb.Append("<orderInfo>");
sb.Append(" <out_tid>2568595011</out_tid>");
sb.Append(" <buyer_id/>");
sb.Append(" <shop_id>55</shop_id>");
sb.Append(" <consignee>蒋先生</consignee>");//收货人姓名
sb.Append(" <buyer_msg>2568595011药师帮已付款旗舰店自营,留言:测试订单 无需发货</seller_remark>");
sb.Append(" <mobilPhone>区锦荣 156****8060</mobilPhone>");
sb.Append(" <express>圆通</express>");
sb.Append(" <address>湖南省长沙市岳麓区银杉路绿地中央广场</address>");
sb.Append(" <is_COD>0</is_COD>");
sb.Append(" <order_totalMoney>1</order_totalMoney>");
sb.Append(" <product_totalMoney>1</product_totalMoney>");
sb.Append(" <pay_date>2019-02-15 09:01:56</pay_date>");
sb.Append(" <order_date>2019-02-15 09:01:56</order_date>");
sb.Append(" <pay_status>已付款</pay_status>");
sb.Append("</orderInfo>");
sb.Append("<product_info>");
sb.Append(" <product_item>");
sb.Append(" <barCode>BCJ</barCode>");
sb.Append(" <product_title>KRACIE牌玫瑰香味糖果32g</product_title>");
sb.Append(" <favorite_money>0</favorite_money>");
sb.Append(" <orderGoods_Num>1</orderGoods_Num>");
sb.Append(" <cost_Price>1</cost_Price>");
sb.Append(" <out_tid>2568595011</out_tid>");
sb.Append(" </product_item>");
sb.Append("</product_info>");
sb.Append("</info>"); MOAPI ProMOAPI = new MOAPI();
ProMOAPI.PostMethod = "get";
string Parm = sb.ToString();
Parm = "xmlvalues=" + Parm;

https://pan.baidu.com/s/16l7tWG3Wtbl7H5liVNkPmw

05-11 22:08