以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]c#格式API接口代码如何转换为FT格式  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=190782)

--  作者:洮沙
--  发布时间:2024/3/3 18:23:00
--  [求助]c#格式API接口代码如何转换为FT格式
老师,有以下C#格式API接口代码如何转为FT格式?能否麻烦老师帮忙转换一下,万分谢谢!
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography;

public class Test{

public const String appId = "数脉分配给你的appid";
public const String appSecurity = "数脉分配给你的appsecurity";

public static string GetMD5(string myString) {
MD5 md5 = new MD5CryptoServiceProvider();
byte[] fromData = System.Text.Encoding.UTF8.GetBytes(myString);
byte[] targetData = md5.ComputeHash(fromData);
string byte2String = null;

for (int i = 0; i < targetData.Length; i++) {
byte2String = byte2String+ targetData[i].ToString("x2");
}
return byte2String;
}

public static void Main(string[] args) {
long t = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds);
String str = appId + "&" + t + "&" + appSecurity;
String sign = GetMD5(str);
String keyword = "关键字,公司名全称、注册号、社会统一信用代码";

HttpWebRequest httpRequest = null;
HttpWebResponse httpResponse = null;

String url = "https://api.shumaidata.com/v4/business4/get?appid="+appId+"×tamp="+t+"&sign="+sign+"&keyword="+keyword;

if (url.Contains("https://")) {
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
} else {
httpRequest = (HttpWebRequest)WebRequest.Create(url);
}
httpRequest.Method = "GET";
try {
httpResponse = (HttpWebResponse)httpRequest.GetResponse();
} catch (WebException ex) {
httpResponse = (HttpWebResponse)ex.Response;
}

Console.WriteLine(httpResponse.StatusCode);
Console.WriteLine(httpResponse.Method);
Console.WriteLine(httpResponse.Headers);
Stream st = httpResponse.GetResponseStream();
StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine("\\n");
}

public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
}

[此贴子已经被作者于2024/3/3 18:24:26编辑过]

--  作者:有点蓝
--  发布时间:2024/3/3 20:26:00
--  
转换网站:https://converter.telerik.com/,转换后把命名空间放入代码里