调用秒滴接口

                                                        我们用于短信发送

 

这里因为我们要调用秒滴的接口,所以我们得用using System.Net.Http;这个空间

 

我们模仿浏览器访问:  HttpClient hc = new HttpClient();

                    ttpResponseMessage hrm = hc.PostAsync(“网页链接”,“网页参数”);

 

 

由于我们妙滴那里需要一个md5的加密

Md5:

        Md5:加密是不可以逆向解密的

            //把字符串转换成字节数组

            byte[] jmq = System.Text.Encoding.Default.GetBytes(str);

 

            MD5 md = new MD5CryptoServiceProvider();

            //通过字符串组转成加密后的字符串组

            byte[] jfjmh = md.ComputeHash(jmq);

            //得到加密后的字符串  并用空格替换掉我们的-

            string strjmh = BitConverter.ToString(jfjmh).Replace("-", "");

 

            return strjmh;

 

 

 

 

这里我们的一个发送的实例:

      HttpClient hc = new HttpClient();

 

            //获取当前时间

            string time = DateTime.Now.ToString("yyyyMMddHHmmss");

            string url = @"https://api.miaodiyun.com/20150822/industrySMS/sendSMS";

 

            List<KeyValuePair<string, string>> keylist = new List<KeyValuePair<string, string>>();

       

            keylist.Add(new KeyValuePair<string, string>("accountSid", "9bb5352e87fc412aad2f3ae9cc5d8644"));

            keylist.Add(new KeyValuePair<string, string>("smsContent", "【星语】尊敬的用户,您的验证码为110"));

            keylist.Add(new KeyValuePair<string, string>("timestamp", time));

            keylist.Add(new KeyValuePair<string, string>("sig", md5("9bb5352e87fc412aad2f3ae9cc5d86445797ac9b01e14f7fa25ec19c1b917ee7" + time).ToLower()));

            keylist.Add(new KeyValuePair<string, string>("to", username));

 

           // keylist.Add(new KeyValuePair<string,string>("templateid", "89405961"));

           // keylist.Add(new KeyValuePair<string,string>("smsContent", "[秒嘀科技]我和你和他"));

           //keylist.Add(new KeyValuePair<string,string>("param", "1541,30"));

            //我们的参数

            HttpContent hcont = new FormUrlEncodedContent(keylist);

            //这里我们等待了  用了异步  我们的方法就必须要用async

            HttpResponseMessage hrm = await hc.PostAsync(url,hcont);

 

            string reslut = await hrm.Content.ReadAsStringAsync();

           

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值