商家推广怎么利用C#发送视频短信

视频短信,这一融合了视频、音频与文本的创新通信方式,不仅革新了传统短信的单一形式,更以其独特的魅力带领着移动通信的新风尚。它以移动视频格式为载体,实现了信息传输的多元化,为用户带来不一样的通信体验。

支持免费试用:乐讯通PaaS平台 找好用的短信平台,选择乐讯通,短信群发|短信平台|群发短信软件|群发短信平台|乐讯通PaaS平台http://yun.loktong.com/login/register/0c61bafb77

复制代码
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinApiDemo
{
    class Program
    {
        private const string url = "http://www.lokapi.cn/smsUTF8.aspx";
        private const string urlReply = "http://www.lokapi.cn/callApi.aspx";
        private const string urlStatus = "http://www.lokapi.cn/statusApi.aspx";
        private const string urlBalance = "http://www.lokapi.cn/smsUTF8.aspx";
        private const string urlKeyword = "http://www.lokapi.cn/checkWord.aspx";
        private const string rece = "json";
        private const string username = "";
        private const string password = "";
        private const string encode = "utf-8";

        //token
        private const string tokenYZM = "";//验证码
        private const string tokenTZ = "";//通知
        private const string tokenYX = "";//营销
        private const string tokenMMS = "";//彩信
        private const string tokenVideo = "";//视频
        private const string tokenSX = "";//闪信
        private const string tokenVoice = "";//语音
        private const string tokenInter = "";//国际
        //模板ID
        private const string templateid = "";
        //参数
        private const string param = "17733861234|2541";

        private const string mobile = "";
        private const string title = "祝福短信";//彩信标题

        static void Main(string[] args)
        {
            string result = "";
            string sign = "";
            string passwordMd5 = Common.Md5Hash(password);
            string ticks = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000).ToString();
            Encoding encoding = Encoding.GetEncoding(encode);

            StringBuilder sb = new StringBuilder();

            #region 文字短信
            sb.AppendFormat("action=sendtemplate&username={0}&password={1}&token={2}&timestamp={3}", username, passwordMd5, tokenYZM, ticks);
            sign = Common.Md5Hash(sb.ToString());
            sb.AppendFormat("&sign={0}&rece={1}", sign, rece);
            sb.AppendFormat("&templateid={0}&param={1}", templateid, param);
            result = Common.HttpPost(url, sb.ToString(), encoding);
            Console.WriteLine(result);
            #endregion

            #region 彩信
            sb.Clear();
            sb.AppendFormat("action=sendimagetext&username={0}&password={1}&token={2}&timestamp={3}", username, passwordMd5, tokenYZM, ticks);
            sign = Common.Md5Hash(sb.ToString());
            sb.AppendFormat("&sign={0}&rece={1}", sign, rece);
            sb.AppendFormat("&mobile={0}&title={1}", mobile, title);
            //彩信发送主体
            //文字
            string content = "祝你生日快乐";
            Encoding encodingGB = Encoding.GetEncoding("gb2312");
            byte[] txt_bytes = encoding.GetBytes(content);
            string txt = Convert.ToBase64String(txt_bytes);
            //图片
            string path = @"D:\我的文档\Pictures\11.jpg";
            string extension = "jpg";//图片后缀
            byte[] bytes = File.ReadAllBytes(path);
            string imgContent = System.Convert.ToBase64String(bytes);
            string message = string.Format("txt|{0},{1}|{2};", txt, extension, imgContent);
            message = message.Replace("%", "%25");
            message = message.Replace("&", "%26");
            message = message.Replace("+", "%2B");
            sb.AppendFormat("&message={0}", message);
            result = Common.HttpPost(url, sb.ToString(), encoding);
            Console.WriteLine(result);
            #endregion

            #region 视频
            sb.Clear();
            sb.AppendFormat("action=sendvideo&username={0}&password={1}&token={2}&timestamp={3}", username, passwordMd5, tokenYZM, ticks);
            sign = Common.Md5Hash(sb.ToString());
            sb.AppendFormat("&sign={0}&rece={1}", sign, rece);
            sb.AppendFormat("&mobile={0}&templateid={1}", mobile, templateid);
            result = Common.HttpPost(url, sb.ToString(), encoding);
            Console.WriteLine(result);
            #endregion

            #region 闪信
            sb.Clear();
            sb.AppendFormat("action=sendshanxin&username={0}&password={1}&token={2}&timestamp={3}", username, passwordMd5, tokenYZM, ticks);
            sign = Common.Md5Hash(sb.ToString());
            sb.AppendFormat("&sign={0}&rece={1}", sign, rece);
            sb.AppendFormat("&templateid={0}&param={1}", templateid, param);
            result = Common.HttpPost(url, sb.ToString(), encoding);
            Console.WriteLine(result);
            #endregion

            #region 语音
            sb.Clear();
            sb.AppendFormat("action=sendvoice&username={0}&password={1}&token={2}&timestamp={3}", username, passwordMd5, tokenYZM, ticks);
            sign = Common.Md5Hash(sb.ToString());
            sb.AppendFormat("&sign={0}&rece={1}", sign, rece);
            sb.AppendFormat("&templateid={0}&param={1}", templateid, param);
            result = Common.HttpPost(url, sb.ToString(), encoding);
            Console.WriteLine(result);
            #endregion

            #region 国际
            sb.Clear();
            sb.AppendFormat("action=sendinternation&username={0}&password={1}&token={2}&timestamp={3}", username, passwordMd5, tokenYZM, ticks);
            sign = Common.Md5Hash(sb.ToString());
            sb.AppendFormat("&sign={0}&rece={1}", sign, rece);
            sb.AppendFormat("&templateid={0}&param={1}", templateid, param);
            result = Common.HttpPost(url, sb.ToString(), encoding);
            Console.WriteLine(result);
            #endregion

            #region 文字回复报告
            sb.Clear();
            sb.AppendFormat("action=sms&username={0}&password={1}&timestamp={2}", username, passwordMd5, ticks);
            sign = Common.Md5Hash(sb.ToString());
            sb.AppendFormat("&sign={0}&rece={1}", sign, rece);
            result = Common.HttpPost(urlReply, sb.ToString(), encoding);
            Console.WriteLine(result);
            #endregion

            #region 状态报告
            sb.Clear();
            //action根据API文档选择合适产品的action
            sb.AppendFormat("action=sms&username={0}&password={1}&timestamp={2}", username, passwordMd5, ticks);
            sign = Common.Md5Hash(sb.ToString());
            sb.AppendFormat("&sign={0}&rece={1}", sign, rece);
            result = Common.HttpPost(urlStatus, sb.ToString(), encoding);
            Console.WriteLine(result);
            #endregion

            #region 余额查询
            sb.Clear();
            sb.AppendFormat("action=overage&username={0}&password={1}&token={2}&timestamp={3}", username, passwordMd5, tokenTZ, ticks);
            sign = Common.Md5Hash(sb.ToString());
            sb.AppendFormat("&sign={0}&rece={1}", sign, rece);
            result = Common.HttpPost(urlBalance, sb.ToString(), encoding);
            Console.WriteLine(result);
            #endregion

            #region 屏蔽词检测
            sb.Clear();
            sb.AppendFormat("username={0}&password={1}&timestamp={2}", username, passwordMd5, ticks);
            sign = Common.Md5Hash(sb.ToString());
            sb.AppendFormat("&sign={0}&rece={1}&message={2}", sign, rece, "您的验证码是5412");
            result = Common.HttpPost(urlKeyword, sb.ToString(), encoding);
            Console.WriteLine(result);
            #endregion

            Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace WinApiDemo
{
    public class Common
    {
        public static string HttpPost(string Url, string Body, Encoding encode)
        {
            string ResponseContent = "";

            try
            {
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(Url);

                httpWebRequest.ContentType = "application/x-www-form-urlencoded";
                httpWebRequest.Method = "POST";
                httpWebRequest.Timeout = 600000; //setInstanceFollowRedirects

                byte[] btBodys = encode.GetBytes(Body);
                httpWebRequest.ContentLength = btBodys.Length;

                Stream reqStream = httpWebRequest.GetRequestStream();
                reqStream.Write(btBodys, 0, btBodys.Length);

                HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();

                Stream resStream = httpWebResponse.GetResponseStream();
                StreamReader streamReader = new StreamReader(resStream, encode);
                ResponseContent = streamReader.ReadToEnd();

                streamReader.Close();
                resStream.Close();
                reqStream.Close();

                streamReader.Dispose();
                resStream.Dispose();
                reqStream.Dispose();

                httpWebResponse.Close();
                httpWebResponse.Dispose();
                httpWebRequest.Abort();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
            return ResponseContent;
        }

        public static string Md5Hash(string input)
        {
            MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
            byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
            StringBuilder sBuilder = new StringBuilder();
            for (int i = 0; i < data.Length; i++)
            {
                sBuilder.Append(data[i].ToString("x2"));
            }
            return sBuilder.ToString().ToUpper();
        }

    }
}
相关推荐
迪康coolmu2 分钟前
基于迪康端点安全一体化管理系统的公用终端上机与信创补丁实战
linux·运维·服务器·网络·安全·电脑
十年Java程序媛3 分钟前
JVM 基础与 GC 垃圾回收详解|可达性分析、分代模型、垃圾收集器、STW
java·开发语言·jvm·spring boot·后端·面试
估值探索者4 分钟前
【Python量化选股流水线 #03】候选股怎么排序?动量+低波+流动性三因子打分取 Top-N
开发语言·python·接口·api接口·股票数据接口·数据接口·股票数据api接口
骑士雄师5 分钟前
supervisor 中关于上下文多轮信息维护常用到的python语法
开发语言·python
曹牧14 分钟前
C#:字符串占位符与值数量不一致
开发语言·数据库·c#
Shadow(⊙o⊙)18 分钟前
仿muduo实现高并发服务器——EPOLL设置与移除Poller.hpp管理Channel
运维·服务器·c++
只睡四小时22 分钟前
Local-First 数据契约:一张表装下 4 类数据
前端·javascript·架构设计·local-first·数据契约
迅猛龙办公室22 分钟前
Python函数实现反转一个只有3位数的整数
开发语言·前端·python
Vitaliy Kostrov(柯维远)24 分钟前
客户端如何检查直播流:从流内标记到停止播放
android·运维·服务器·驱动开发·网络安全·系统架构·cdn
软件工程师文艺24 分钟前
PLM系统的下一个十年:从MBD模型定义到产线仿真的技术路线拆解
运维·服务器·网络