zoukankan      html  css  js  c++  java
  • 接口请求的例子

    string api_url = ConfigurationManager.AppSettings["api_url"].ToString();
                                string key = ConfigurationManager.AppSettings["app_key"].ToString();
                                string secret = ConfigurationManager.AppSettings["app_secret"].ToString();
                                string app_key = "app_key=" + key;
                                string app_secret = "app_secret=" + md5(secret);
                                string submitUrl = api_url + "?" + app_key + "&" + app_secret;//提交地址

                                //string aass = ReafHtml(submitUrl);
                                UTF8Encoding encoding = new UTF8Encoding();

                                string postData = "interface=" + xml;
                                byte[] data = encoding.GetBytes(postData);

                                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(submitUrl);
                                myRequest.Method = "POST";


                                myRequest.ContentType = "application/x-www-form-urlencoded;";
                                myRequest.ContentLength = data.Length;
                                Stream newStream = myRequest.GetRequestStream();

                                // Send the data.
                                newStream.Write(data, 0, data.Length);
                                newStream.Close();

                                // Get response
                                HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                                StreamReader reader = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8"));
                                string content = reader.ReadToEnd();

  • 相关阅读:
    jmeter分布式配置
    APP自动化测试获取包名的两种方法
    Monkey自动化测试命令
    jmeter之http请求用csv读取中文乱码
    jmeter断言之响应code:200
    使用 form 和 iframe 实现图片上传回显
    sublime3 破解
    在cmd下面执行.py文件时提示ModuleNotFoundError 但是 IDE 不报错
    windows 开启 nginx 监听80 端口 以及 禁用 http 服务后,无法重启 HTTP 服务,提示 系统错误 123,文件目录、卷标出错
    python打包exe
  • 原文地址:https://www.cnblogs.com/doosmile/p/2440857.html
Copyright © 2011-2022 走看看