This commit is contained in:
2025-05-13 12:47:28 +08:00
parent b95a465d96
commit f67b9d5474
2 changed files with 50 additions and 53 deletions

View File

@@ -49,20 +49,21 @@ public class GainfoFacesController : ControllerBase
var key = "27390082";
var secret = "MLl7Dv7p5Pgc9XYI3r4O";
// HttpUtillib.SetPlatformInfo(key, secret, "10.32.0.10");
// HttpUtillib.HttpPost(url, body, 15);
HttpUtillib.SetPlatformInfo(key, secret, "10.32.0.10");
var r = HttpUtillib.HttpPost(url, body, 15);
return Encoding.UTF8.GetString(r);
var headers = InitRequest(url, body, key, secret);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(headers["Accept"]));
var content = new StringContent(body, Encoding.UTF8, "application/json");
foreach (var item in headers.Where(x => x.Key != "Accept").Where(x => x.Key != "Content-Type"))
{
content.Headers.Add(item.Key, item.Value);
}
var r = await client.PostAsync(url, content);
return await r.Content.ReadAsStringAsync();
// var headers = InitRequest(url, body, key, secret);
// client.DefaultRequestHeaders.Accept.Clear();
// client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(headers["Accept"]));
// var content = new StringContent(body, Encoding.UTF8, "application/json");
// foreach (var item in headers.Where(x => x.Key != "Accept").Where(x => x.Key != "Content-Type"))
// {
// content.Headers.Add(item.Key, item.Value);
// }
//
// var r = await client.PostAsync(url, content);
// return await r.Content.ReadAsStringAsync();
}
private static Dictionary<string, string> InitRequest(string url, string body, string key, string secret)