电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

eoLinker-API_Shop_常见疾病查询_API接口_C#调用示例代码

18页
  • 卖家[上传人]:亿***
  • 文档编号:42585017
  • 上传时间:2018-06-02
  • 文档格式:DOCX
  • 文档大小:13.35KB
  • / 18 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 1、eoLinker-API Shop 常常见见疾病疾病查询查询 C#调调用示例代用示例代码码常常见见疾病疾病查询查询提供所患疾病的病因、症状、检查、用药、治疗、并发症等方面的详细分析资料该产该产品品拥拥有以下有以下APIs: :1.获取疾病部位列表2.通过部位获取疾病列表3.关键字获取疾病列表4.获取疾病列表5.查询疾病信息6.通过症状获取疾病列表注意,注意,该该示例代示例代码仅码仅适用于适用于 网站下网站下API 使用使用该产该产品前,您需要通品前,您需要通过过 https:/ 申申请请API服服务务1.获获取疾病部位列表取疾病部位列表 using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Text; using System.Web.Script.Serialization;namespace apishop_sdk class Program/* 转发请求到目的主机* param method string 请求方法* param url st

      2、ring 请求地址* param params Dictionary 请求参数* param headers Dictionary 请求头* return string*/static string apishop_send_request(string method, string url, Dictionary param, Dictionary headers)string result = string.Empty;trystring paramData = “;if (param != null foreach (var item in param)if (sbuilder.Length 0)sbuilder.Append(“sbuilder.Append(item.Key + “=“ + item.Value);paramData = sbuilder.ToString();method = method.ToUpper();if (method = “GET“)url = string.Format(“0?1“, url, paramData);HttpWebReques

      3、t wbRequest = (HttpWebRequest)WebRequest.Create(url);if (method = “GET“)wbRequest.Method = “GET“;else if (method = “POST“)wbRequest.Method = “POST“;wbRequest.ContentType = “application/x-www-form- urlencoded“;wbRequest.ContentLength = Encoding.UTF8.GetByteCount(paramData);using (Stream requestStream = wbRequest.GetRequestStream()using (StreamWriter swrite = new StreamWriter(requestStream)swrite.Write(paramData);HttpWebResponse wbResponse = (HttpWebResponse)wbRequest.GetResponse();using (Stream r

      4、esponseStream = wbResponse.GetResponseStream()using (StreamReader sread = new StreamReader(responseStream)result = sread.ReadToEnd();catchreturn “;return result;class Responsepublic string statusCode;static void Main(string args)string method = “POST“;string url = “https:/ param = new Dictionary(); param.Add(“apiKey“, “your_api_key“); /需要从获取 Dictionary headers = null;string result = apishop_send_request(method, url, param, headers);if (result = “)/返回内容异常,发送请求失败Console.WriteLine(“发送请求失败“);return;

      5、Response res = new JavaScriptSerializer().Deserialize(result);if (res.statusCode = “000000“)/状态码为000000, 说明请求成功Console.WriteLine(string.Format(“请求成功: 0“, result);else/状态码非000000, 说明请求失败Console.WriteLine(string.Format(“请求失败: 0“, result);Console.ReadLine(); 2.通通过过部位部位获获取疾病列表取疾病列表 using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Text; using System.Web.Script.Serialization;namespace apishop_sdk class Program/* 转发请求到目的主机* param method string 请求方法* param

      6、url string 请求地址* param params Dictionary 请求参数* param headers Dictionary 请求头* return string*/static string apishop_send_request(string method, string url, Dictionary param, Dictionary headers)string result = string.Empty;trystring paramData = “;if (param != null foreach (var item in param)if (sbuilder.Length 0)sbuilder.Append(“sbuilder.Append(item.Key + “=“ + item.Value);paramData = sbuilder.ToString();method = method.ToUpper();if (method = “GET“)url = string.Format(“0?1“, url, paramData);HttpWeb

      7、Request wbRequest = (HttpWebRequest)WebRequest.Create(url);if (method = “GET“)wbRequest.Method = “GET“;else if (method = “POST“)wbRequest.Method = “POST“;wbRequest.ContentType = “application/x-www-form- urlencoded“;wbRequest.ContentLength = Encoding.UTF8.GetByteCount(paramData);using (Stream requestStream = wbRequest.GetRequestStream()using (StreamWriter swrite = new StreamWriter(requestStream)swrite.Write(paramData);HttpWebResponse wbResponse = (HttpWebResponse)wbRequest.GetResponse();using (St

      8、ream responseStream = wbResponse.GetResponseStream()using (StreamReader sread = new StreamReader(responseStream)result = sread.ReadToEnd();catchreturn “;return result;class Responsepublic string statusCode;static void Main(string args)string method = “POST“;string url = “https:/ param = new Dictionary(); param.Add(“apiKey“, “your_api_key“); /需要从获取 param.Add(“page“, “); /当前页码(默认1) param.Add(“pageSize“, “); /该页疾病数量(默认15) param.Add(“site“, “); /发病部位 Dictionary headers = null;string result = apishop

      9、_send_request(method, url, param, headers);if (result = “)/返回内容异常,发送请求失败Console.WriteLine(“发送请求失败“);return;Response res = new JavaScriptSerializer().Deserialize(result);if (res.statusCode = “000000“)/状态码为000000, 说明请求成功Console.WriteLine(string.Format(“请求成功: 0“, result);else/状态码非000000, 说明请求失败Console.WriteLine(string.Format(“请求失败: 0“, result);Console.ReadLine(); 3.关关键键字字获获取疾病列表取疾病列表 using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Text; using System.Web.Script.Serialization;namespace

      《eoLinker-API_Shop_常见疾病查询_API接口_C#调用示例代码》由会员亿***分享,可在线阅读,更多相关《eoLinker-API_Shop_常见疾病查询_API接口_C#调用示例代码》请在金锄头文库上搜索。

      点击阅读更多内容
    关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
    手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
    ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.