接口文件

This commit is contained in:
“wanyongkang”
2024-04-10 13:55:27 +08:00
parent fff6bee06a
commit ed3b2c653e
3190 changed files with 268248 additions and 1 deletions

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
namespace Hncore.Infrastructure.Common
{
public static class HttpHelp
{
/// <summary>
/// get请求
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static string HttpGet(string url)
{
string result = string.Empty;
try
{
HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.Create(url);
wbRequest.Method = "GET";
HttpWebResponse wbResponse = (HttpWebResponse)wbRequest.GetResponse();
using (Stream responseStream = wbResponse.GetResponseStream())
{
using (StreamReader sReader = new StreamReader(responseStream))
{
result = sReader.ReadToEnd();
}
}
}
catch/* (Exception ex) 此处暂时屏蔽掉了,要不然编译光弹出变量未使用的警告,谁用得着再打开*/
{
}
return result;
}
/// <summary>
/// get 请求带token
/// </summary>
/// <param name="token"></param>
/// <param name="url"></param>
/// <returns></returns>
public static string HttpGet(string token,string url)
{
string result = string.Empty;
try
{
HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.Create(url);
wbRequest.Headers.Add("token", token);
wbRequest.Method = "GET";
HttpWebResponse wbResponse = (HttpWebResponse)wbRequest.GetResponse();
using (Stream responseStream = wbResponse.GetResponseStream())
{
using (StreamReader sReader = new StreamReader(responseStream))
{
result = sReader.ReadToEnd();
}
}
}
catch/* (Exception ex) 此处暂时屏蔽掉了,要不然编译光弹出变量未使用的警告,谁用得着再打开*/
{
}
return result;
}
}
}