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();

  • 相关阅读:
    python生成四位随机数
    解决mysql远程连接失败的问题
    python中的sort、sorted排序
    rest_framework之status HTTP状态码
    vim的卸载以及环境的配置小记
    vue项目如何引用jquery
    VSCode 安装Vue 插件
    Element-UI tree 组件 点击后高亮显示的样式修改(背景色)
    webstorm安装vue插件及安装过程出现的问题
    Vue el-date-picker 日期组件的使用
  • 原文地址:https://www.cnblogs.com/doosmile/p/2440857.html
Copyright © 2011-2022 走看看