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

2024-08-31 12:28

本文主要是介绍商家推广怎么利用C#发送视频短信,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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

支持免费试用:乐讯通PaaS平台 找好用的短信平台,选择乐讯通,短信群发|短信平台|群发短信软件|群发短信平台|乐讯通PaaS平台icon-default.png?t=N7T8http://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";//tokenprivate 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 = "";//国际//模板IDprivate 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文档选择合适产品的actionsb.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);#endregionConsole.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; //setInstanceFollowRedirectsbyte[] 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();}}
}

这篇关于商家推广怎么利用C#发送视频短信的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1123903

相关文章

python运用requests模拟浏览器发送请求过程

《python运用requests模拟浏览器发送请求过程》模拟浏览器请求可选用requests处理静态内容,selenium应对动态页面,playwright支持高级自动化,设置代理和超时参数,根据需... 目录使用requests库模拟浏览器请求使用selenium自动化浏览器操作使用playwright

C#中lock关键字的使用小结

《C#中lock关键字的使用小结》在C#中,lock关键字用于确保当一个线程位于给定实例的代码块中时,其他线程无法访问同一实例的该代码块,下面就来介绍一下lock关键字的使用... 目录使用方式工作原理注意事项示例代码为什么不能lock值类型在C#中,lock关键字用于确保当一个线程位于给定实例的代码块中时

C# $字符串插值的使用

《C#$字符串插值的使用》本文介绍了C#中的字符串插值功能,详细介绍了使用$符号的实现方式,文中通过示例代码介绍的非常详细,需要的朋友们下面随着小编来一起学习学习吧... 目录$ 字符使用方式创建内插字符串包含不同的数据类型控制内插表达式的格式控制内插表达式的对齐方式内插表达式中使用转义序列内插表达式中使用

C#中的Converter的具体应用

《C#中的Converter的具体应用》C#中的Converter提供了一种灵活的类型转换机制,本文详细介绍了Converter的基本概念、使用场景,具有一定的参考价值,感兴趣的可以了解一下... 目录Converter的基本概念1. Converter委托2. 使用场景布尔型转换示例示例1:简单的字符串到

C#监听txt文档获取新数据方式

《C#监听txt文档获取新数据方式》文章介绍通过监听txt文件获取最新数据,并实现开机自启动、禁用窗口关闭按钮、阻止Ctrl+C中断及防止程序退出等功能,代码整合于主函数中,供参考学习... 目录前言一、监听txt文档增加数据二、其他功能1. 设置开机自启动2. 禁止控制台窗口关闭按钮3. 阻止Ctrl +

C#解析JSON数据全攻略指南

《C#解析JSON数据全攻略指南》这篇文章主要为大家详细介绍了使用C#解析JSON数据全攻略指南,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录一、为什么jsON是C#开发必修课?二、四步搞定网络JSON数据1. 获取数据 - HttpClient最佳实践2. 动态解析 - 快速

C#连接SQL server数据库命令的基本步骤

《C#连接SQLserver数据库命令的基本步骤》文章讲解了连接SQLServer数据库的步骤,包括引入命名空间、构建连接字符串、使用SqlConnection和SqlCommand执行SQL操作,... 目录建议配合使用:如何下载和安装SQL server数据库-CSDN博客1. 引入必要的命名空间2.

Python办公自动化实战之打造智能邮件发送工具

《Python办公自动化实战之打造智能邮件发送工具》在数字化办公场景中,邮件自动化是提升工作效率的关键技能,本文将演示如何使用Python的smtplib和email库构建一个支持图文混排,多附件,多... 目录前言一、基础配置:搭建邮件发送框架1.1 邮箱服务准备1.2 核心库导入1.3 基础发送函数二、

C#读写文本文件的多种方式详解

《C#读写文本文件的多种方式详解》这篇文章主要为大家详细介绍了C#中各种常用的文件读写方式,包括文本文件,二进制文件、CSV文件、JSON文件等,有需要的小伙伴可以参考一下... 目录一、文本文件读写1. 使用 File 类的静态方法2. 使用 StreamReader 和 StreamWriter二、二进

C#中Guid类使用小结

《C#中Guid类使用小结》本文主要介绍了C#中Guid类用于生成和操作128位的唯一标识符,用于数据库主键及分布式系统,支持通过NewGuid、Parse等方法生成,感兴趣的可以了解一下... 目录前言一、什么是 Guid二、生成 Guid1. 使用 Guid.NewGuid() 方法2. 从字符串创建