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

  • 相关阅读:
    低成本两台服务器备份,SQL SERVER数据库镜像(二)
    Entity Framework多表对一实体,一表对多实体的实现
    数字的与或非处理表中的多个状态(二)
    基于角色的权限原理
    数字与或非处理表中的多个状态(一)
    双服务器同步实施办法
    精彩博文收集目录索引
    个人文章目录索引
    Web常用函数介绍(LoadRunner相关)
    Rhythmbox中文乱码
  • 原文地址:https://www.cnblogs.com/doosmile/p/2440857.html
Copyright © 2011-2022 走看看