• 接口请求的例子


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

  • 相关阅读:
    Golang 入门~~基础知识
    Redis命令总结
    CI框架在辅助函数中使用配置文件中的变量
    前后端分离--三层
    前后端分层--两层
    JavaScript中的cookie
    JavaScript的类、对象、原型、继承、引用
    Qt编写自定义控件46-树状导航栏
    Qt编写自定义控件45-柱状标尺控件
    Qt编写自定义控件44-天气仪表盘
  • 原文地址:https://www.cnblogs.com/doosmile/p/2440857.html
Copyright © 2020-2023  润新知