zoukankan      html  css  js  c++  java
  • .net短信接口调用示例(106短信通道)

    1. [代码]调用代理示例     

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.IO;
    using System.Net;
    using System.Text;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
     
    public partial class Post : System.Web.UI.Page
    {
        public static string PostUrl = ConfigurationManager.AppSettings["WebReference.Service.PostUrl"];
        protected void Page_Load(object sender, EventArgs e)
        {
     
        }
        protected void ButSubmit_Click(object sender, EventArgs e)
        {
            string sname = this.TxtSname.Text.Trim();
            string spwd = this.TxtSpwd.Text.Trim();
            string scorpid = this.TxtScorpid.Text.Trim();
            string sprdid = this.TxtSprdid.Text.Trim();
            string sdst = this.TxtSdst.Text.Trim();
            string smsg = this.TxtSmsg.Text.Trim();
     
            string postStrTpl = "sname={0}&spwd={1}&scorpid={2}&sprdid={3}&sdst={4}&smsg={5}";
     
            UTF8Encoding encoding = new UTF8Encoding();
            byte[] postData = encoding.GetBytes(string.Format(postStrTpl, sname, spwd, scorpid, sprdid, sdst, smsg));
     
            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(PostUrl);
            myRequest.Method = "POST";http://www.enterdesk.com/special/huangguantp/
            myRequest.ContentType = "application/x-www-form-urlencoded";
            myRequest.ContentLength = postData.Length;
     
            Stream newStream = myRequest.GetRequestStream();
            // Send the data.高清壁纸
            newStream.Write(postData, 0, postData.Length);
            newStream.Flush();
            newStream.Close();
     
            HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
            if (myResponse.StatusCode == HttpStatusCode.OK)
            {
                StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
                LabelRetMsg.Text = reader.ReadToEnd();
                //反序列化upfileMmsMsg.Text
                //实现自己的逻辑
            }
            else
            {
                //访问失败
            }
        }
    }

  • 相关阅读:
    zend framework多模块配置
    java解析xml的几种方式
    jdbc操作步骤和preparedStatment相比Statment的好处
    Android UI 之实现多级列表TreeView
    python小游戏实现代码
    【iOS知识学习】_UITableView简介
    根据指定电话号码得到通讯录上的姓名
    HDU 4705 Y
    C#实现的内存分页机制的一个实例
    【编程程序猿艺术】学习记录1:指针向左翻转法的旋转串
  • 原文地址:https://www.cnblogs.com/xkzy/p/3966700.html
Copyright © 2011-2022 走看看