商家推广怎么利用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

相关文章

C# 比较两个list 之间元素差异的常用方法

《C#比较两个list之间元素差异的常用方法》:本文主要介绍C#比较两个list之间元素差异,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录1. 使用Except方法2. 使用Except的逆操作3. 使用LINQ的Join,GroupJoin

java向微信服务号发送消息的完整步骤实例

《java向微信服务号发送消息的完整步骤实例》:本文主要介绍java向微信服务号发送消息的相关资料,包括申请测试号获取appID/appsecret、关注公众号获取openID、配置消息模板及代码... 目录步骤1. 申请测试系统2. 公众号账号信息3. 关注测试号二维码4. 消息模板接口5. Java测试

怎么用idea创建一个SpringBoot项目

《怎么用idea创建一个SpringBoot项目》本文介绍了在IDEA中创建SpringBoot项目的步骤,包括环境准备(JDK1.8+、Maven3.2.5+)、使用SpringInitializr... 目录如何在idea中创建一个SpringBoot项目环境准备1.1打开IDEA,点击New新建一个项

qt5cored.dll报错怎么解决? 电脑qt5cored.dll文件丢失修复技巧

《qt5cored.dll报错怎么解决?电脑qt5cored.dll文件丢失修复技巧》在进行软件安装或运行程序时,有时会遇到由于找不到qt5core.dll,无法继续执行代码,这个问题可能是由于该文... 遇到qt5cored.dll文件错误时,可能会导致基于 Qt 开发的应用程序无法正常运行或启动。这种错

电脑提示xlstat4.dll丢失怎么修复? xlstat4.dll文件丢失处理办法

《电脑提示xlstat4.dll丢失怎么修复?xlstat4.dll文件丢失处理办法》长时间使用电脑,大家多少都会遇到类似dll文件丢失的情况,不过,解决这一问题其实并不复杂,下面我们就来看看xls... 在Windows操作系统中,xlstat4.dll是一个重要的动态链接库文件,通常用于支持各种应用程序

Python使用smtplib库开发一个邮件自动发送工具

《Python使用smtplib库开发一个邮件自动发送工具》在现代软件开发中,自动化邮件发送是一个非常实用的功能,无论是系统通知、营销邮件、还是日常工作报告,Python的smtplib库都能帮助我们... 目录代码实现与知识点解析1. 导入必要的库2. 配置邮件服务器参数3. 创建邮件发送类4. 实现邮件

C#如何去掉文件夹或文件名非法字符

《C#如何去掉文件夹或文件名非法字符》:本文主要介绍C#如何去掉文件夹或文件名非法字符的问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录C#去掉文件夹或文件名非法字符net类库提供了非法字符的数组这里还有个小窍门总结C#去掉文件夹或文件名非法字符实现有输入字

C#之List集合去重复对象的实现方法

《C#之List集合去重复对象的实现方法》:本文主要介绍C#之List集合去重复对象的实现方法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录C# List集合去重复对象方法1、测试数据2、测试数据3、知识点补充总结C# List集合去重复对象方法1、测试数据

C#实现将Office文档(Word/Excel/PDF/PPT)转为Markdown格式

《C#实现将Office文档(Word/Excel/PDF/PPT)转为Markdown格式》Markdown凭借简洁的语法、优良的可读性,以及对版本控制系统的高度兼容性,逐渐成为最受欢迎的文档格式... 目录为什么要将文档转换为 Markdown 格式使用工具将 Word 文档转换为 Markdown(.

Java调用C#动态库的三种方法详解

《Java调用C#动态库的三种方法详解》在这个多语言编程的时代,Java和C#就像两位才华横溢的舞者,各自在不同的舞台上展现着独特的魅力,然而,当它们携手合作时,又会碰撞出怎样绚丽的火花呢?今天,我们... 目录方法1:C++/CLI搭建桥梁——Java ↔ C# 的“翻译官”步骤1:创建C#类库(.NET