class ITInfo_SFC { public bool bPingFaile = false; HttpWebRequest http; public Server server; public string url = "https://www.baidu.com/"; public string SFC_ip = "127.0.0.1"; public static bool OnLine() { //public string SFC_ip ="127.0.0.1"; Ping ping = new Ping(); PingReply pingReply = ping.Send("127.0.0.1"); if (pingReply.Status == IPStatus.Success) { return true; } else return false; } public void InitURLValue(string url) { this.url = url; http = WebRequest.CreateHttp(url) as HttpWebRequest; } public static string PostToUrl(string requestUrl, byte[] byteArrayPost, Encoding encoding) { if (OnLine()) { try { string stringResponse = ""; HttpWebRequest webRequest = WebRequest.CreateHttp(url) as HttpWebRequest; webRequest.Method = "POST"; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.ContentLength = byteArrayPost.Length; webRequest.CookieContainer = new CookieContainer(); webRequest.Credentials = CredentialCache.DefaultCredentials; Stream newStream = webRequest.GetRequestStream(); //写入参数 newStream.Write(byteArrayPost, 0, byteArrayPost.Length); newStream.Close(); WebResponse webResponse = webRequest.GetResponse(); StreamReader responseStream = new StreamReader(webResponse.GetResponseStream(), encoding); stringResponse = responseStream.ReadToEnd(); webResponse.Close(); responseStream.Close(); return stringResponse; } catch (Exception) { } } } }
HttpWebRequest的个人见解
汇通天下物流、 订单处理、 易佰、 深耕几年的类目惨遭黑心大卖"绞杀",反击还是放弃?、 亚马逊新手卖家看过来,亚马逊产品订单管理(自发货流程)&如何进行产品退货、 【实操】如何创建移除订单--弃置商品、 为什么选择亚马逊FBA?亚马逊FBA运送流程是怎样的?、 收集整理的一份干货,亚马逊站外引流篇!、 亚马逊选品精讲课程、 沃尔码、 FBA的优劣势分析、 速卖通站外引流怎么做?如何开展YouTube推广?、 亚马逊cpc广告投放时间段,亚马逊cpc广告投放有什么技巧?、 亚马逊品牌分析上新功能 / DHL在非洲推出电商购物APP、 环金科技、 2019亚马逊各站点FBA和佣金费用调整及优惠活动一览表!、
没有评论:
发表评论