https://op.zto.cn/#/document?menuId=29
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static async Task Main(string[] args)
{
var appKey = "d577e7b5024ad20446e10";
var appSec = "0e8e9457d493666ee2f5adb783e69abb";
var js;
using (HttpClient client = new HttpClient())
{
using (var content = new StringContent(jsonStr, Encoding.UTF8, "application/json"))
{
content.Headers.Add("x-appKey", appKey);
var digest = GetSign(jsonStr, appKey, appSec);
content.Headers.Add("x-datadigest", digest);
HttpResponseMessage response = await client.PostAsync("https://japi-test.zto.com/zto.open.getOrderInfo", content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
}
Console.ReadLine();
}
public static String GetSign(String content,String appKey, String appSec)
{
String fullContent = content + appSec;
byte[] buytes = Encoding.GetEncoding("UTF-8").GetBytes(fullContent);
using (MD5 md5 = new MD5CryptoServiceProvider())
{
var outBytes = md5.ComputeHash(buytes);
return Convert.ToBase64String(outBytes);
}
}
}
}
还是一样,先用转换代码的转换是吧
http://converter.telerik.com/
[此贴子已经被作者于2021/1/11 15:29:02编辑过]