Foxtable(狐表)用户栏目专家坐堂 → [求助]c#格式API接口代码如何转换为FT格式


  共有1255人关注过本帖树形打印复制链接

主题:[求助]c#格式API接口代码如何转换为FT格式

帅哥哟,离线,有人找我吗?
洮沙
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:826 积分:7130 威望:0 精华:0 注册:2017/8/31 12:07:00
[求助]c#格式API接口代码如何转换为FT格式  发帖心情 Post By:2024/3/3 18:23:00 [只看该作者]

老师,有以下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编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110738 积分:563610 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2024/3/3 20:26:00 [只看该作者]

转换网站:https://converter.telerik.com/,转换后把命名空间放入代码里

 回到顶部