发送请求读取接口
来源:互联网 发布:网络打鱼游戏作弊教程 编辑:程序博客网 时间:2024/06/03 16:38
private static Dictionary<int, int> GetCRMUserTypeNew(string phoneNo, string imeiNo) { Dictionary<int, int> diction = new Dictionary<int, int>(); try { // 发送请求 string url = ConfigurationManager.AppSettings["CRMVipSrvUrl"] + "GetVipUserInfo"; string data = string.Format(@"{{""name"":""getvip"",""pwd"":""getvip@0701"",""phone"":""{0}"",""imei"":""{1}""}}" , phoneNo == null ? "" : phoneNo.TrimStart('0'), imeiNo == null ? "" : imeiNo); byte[] requestBuffer = Encoding.GetEncoding("utf-8").GetBytes(data); WebRequest request = WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = requestBuffer.Length; using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(requestBuffer, 0, requestBuffer.Length); requestStream.Close(); } WebResponse response = request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"))) { string str = reader.ReadToEnd(); reader.Close(); JavaScriptArray billArray = (JavaScriptArray)JavaScriptConvert.DeserializeObject(str); if (billArray != null) { for (int i = 0; i < billArray.Count; i++) { JavaScriptObject bill = (billArray[i]) as JavaScriptObject; JavaScriptArray vipArray = bill["vip"] as JavaScriptArray; if (vipArray != null) { for (int j = 0; j < vipArray.Count; j++) { JavaScriptObject vip = (vipArray[j]) as JavaScriptObject; int userTypeId = GetUserTypeId(vip["type"].ToString()); int vipLevel = SqlUtils.DBToInt(vip["level"]); if(!diction.ContainsKey(userTypeId)) { diction.Add(userTypeId, vipLevel); } } } } } } } catch (Exception ex) { } return diction; }
0 0
- 发送请求读取接口
- 根据接口服务端发送请求
- java读取EXCEL并且发送post请求
- 使用HttpRequester发送json请求测试接口
- httpClient发送get请求调用接口
- jmeter发送soap请求-webservice接口
- 【接口测试】:HttpURLConnection 发送post请求
- 门外小白用axis2调用接口,发送数据请求
- 【接口测试】:HttpURLConnection 发送get请求
- python接口自动化1-发送get请求
- python接口自动化2-发送post请求
- httpClient使用,1 发送post请求 2 发送get请求取得接口中的数据
- 利用Ajax发送HEAD请求读取服务器响应头部
- 利用Ajax发送HEAD请求读取服务器响应头部
- java读取网络资源文件(用于请求短信发送功能)
- PHP如何向.NET接口webservice发送xml请求
- jmeter发送soap请求进行webservice接口压力测试
- C#通过发送 http 请求调用接口之Get
- 高手速成android开源项目【View篇】
- 什么才是真智能家居?
- good material for STL
- 心动不如行动, 盘点职场实干者的10大标志
- 关于C++/C中防止头文件的重复包含的解决办法 (转)
- 发送请求读取接口
- 面试通过——阿里校招面试总结
- Js中 关于top、clientTop、scrollTop、offsetTop等
- Android 编程下使用 Google 的 Gson 解析 Json
- squid+apache实现缓存加速
- mysql生产环境____主从同步修复案例
- mac下查看jre路径
- String,StringBuffer和StringBuild 区别
- Eclipse Ganymede:深入Equinox p2(供应平台)