接口调试,HttpWebRequest和HttpWebResponse使用…
2018-06-23 13:22:27来源:未知 阅读 ()
public void queryIdCardSelects
{
string url=“jiekoudizhi.html”;
string param="jiekoucanshu";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
byte[] data = Encoding.UTF8.GetBytes(param);
request.ContentLength = data.Length;
using (Stream reqStream = request.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
string result = "";
HttpWebResponse resp = (HttpWebResponse)request.GetResponse();
Stream stream = resp.GetResponseStream();
//获取响应内容
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
}
接口回调数据处理
TextReader read = new StreamReader(Request.InputStream, Encoding.UTF8);
string READSTR = read.ReadToEnd();
READSTR = HttpUtility.UrlDecode(READSTR, Encoding.GetEncoding("utf-8"));
log.Info(READSTR);
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
下一篇:值类型与引用类型
- Swagger 生成 PHP API 接口文档详细步骤 2019-09-23
- php开发中PhpStorm本地断点调试的方法步骤! 2019-09-17
- Thinkphp5微信小程序获取用户信息接口的实例详解 2019-08-27
- 作为程序员,你是如何有效的调试bug的 2019-08-23
- 用PHP调用微博接口实现微博登录,可参考学习下! 2019-08-23
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash
