zoukankan      html  css  js  c++  java
  • HttpWebRequest的使用方法

    需要在WinForm里调用一个url发送短信,为了防止自己忘记,特将HttpWebRequest的使用方法摘录如下:

     1        public void SendSms(string phoneNumber, string text)
     2        {
     3            string url;
     4            url = string.Format(@"http://a.b.c.d/path/?user=username&password=password&phonenumber={0}&text={1}&charset=gb2312", phoneNumber, HttpUtility.UrlEncode(text));
     5
     6            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
     7
     8            request.MaximumResponseHeadersLength = 10240;
     9            request.Credentials = CredentialCache.DefaultCredentials;
    10            request.Method = "GET";
    11            request.Timeout = 60000;
    12            WebResponse webRep = request.GetResponse();
    13
    14            Debug.WriteLine(webRep.Headers.ToString());
    15            Debug.WriteLine(webRep.ResponseUri.OriginalString);
    16
    17            读取网页内容/不需要
    43
    44            // Release the resources of response object.
    45            webRep.Close();
    46
    47        }
  • 相关阅读:
    Python环境搭建后,多种方式的使用进行程序的执行。
    Visual Studio 2017进行Python开发环境的搭建,使用VS2017进行python代码的编写。
    Linux Ubuntu运行线程程序出现undefined reference to ‘pthread_create’和undefined reference to ‘pthread_join’错误。
    计算机二级-C语言-程序填空题-190107记录
    2018/03/08 每日一学PHP 之 常量defind 和 const区别
    H5手机页面剖析
    jQuery(三)
    jQuery(二)
    jQuery(一)
    JS构造函数(便于理解,简易)
  • 原文地址:https://www.cnblogs.com/CuteNet/p/1420576.html
Copyright © 2011-2022 走看看