| | |
| | | /// <returns></returns> |
| | | public static async System.Threading.Tasks.Task<string> HttpWebRequest(string getUrl, string str, string method, int second = 3, bool _bool = false) |
| | | { |
| | | try
|
| | | {
|
| | | HttpWebRequest request = WebRequest.Create(getUrl) as HttpWebRequest; //创建请求 |
| | | request.Method = method; //请求方式为POST/GET |
| | | request.ContentType = "application/json"; |
| | | request.Timeout = second * 1000;//超时时间 |
| | | if (_bool) { |
| | | if (_bool)
|
| | | {
|
| | | //用于高胜可视对讲接口 |
| | | request.Headers.Add("Authorization", Config.Instance.Token); |
| | | } |
| | |
| | | string content = sr.ReadToEnd(); //获得响应字符串 |
| | | return content; |
| | | } |
| | | catch |
| | | {
|
| | | return null;
|
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 请求服务器的方法 |
| | | /// </summary> |