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

相关文章

SpringBoot基于配置实现短信服务策略的动态切换

《SpringBoot基于配置实现短信服务策略的动态切换》这篇文章主要为大家详细介绍了SpringBoot在接入多个短信服务商(如阿里云、腾讯云、华为云)后,如何根据配置或环境切换使用不同的服务商,需... 目录目标功能示例配置(application.yml)配置类绑定短信发送策略接口示例:阿里云 & 腾

C# foreach 循环中获取索引的实现方式

《C#foreach循环中获取索引的实现方式》:本文主要介绍C#foreach循环中获取索引的实现方式,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、手动维护索引变量二、LINQ Select + 元组解构三、扩展方法封装索引四、使用 for 循环替代

C# Where 泛型约束的实现

《C#Where泛型约束的实现》本文主要介绍了C#Where泛型约束的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录使用的对象约束分类where T : structwhere T : classwhere T : ne

C#实现将Excel表格转换为图片(JPG/ PNG)

《C#实现将Excel表格转换为图片(JPG/PNG)》Excel表格可能会因为不同设备或字体缺失等问题,导致格式错乱或数据显示异常,转换为图片后,能确保数据的排版等保持一致,下面我们看看如何使用C... 目录通过C# 转换Excel工作表到图片通过C# 转换指定单元格区域到图片知识扩展C# 将 Excel

C#中async await异步关键字用法和异步的底层原理全解析

《C#中asyncawait异步关键字用法和异步的底层原理全解析》:本文主要介绍C#中asyncawait异步关键字用法和异步的底层原理全解析,本文给大家介绍的非常详细,对大家的学习或工作具有一... 目录C#异步编程一、异步编程基础二、异步方法的工作原理三、代码示例四、编译后的底层实现五、总结C#异步编程

电脑死机无反应怎么强制重启? 一文读懂方法及注意事项

《电脑死机无反应怎么强制重启?一文读懂方法及注意事项》在日常使用电脑的过程中,我们难免会遇到电脑无法正常启动的情况,本文将详细介绍几种常见的电脑强制开机方法,并探讨在强制开机后应注意的事项,以及如何... 在日常生活和工作中,我们经常会遇到电脑突然无反应的情况,这时候强制重启就成了解决问题的“救命稻草”。那

C#TextBox设置提示文本方式(SetHintText)

《C#TextBox设置提示文本方式(SetHintText)》:本文主要介绍C#TextBox设置提示文本方式(SetHintText),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录C#TextBox设置提示文本效果展示核心代码总结C#TextBox设置提示文本效果展示核心代

C#中DrawCurve的用法小结

《C#中DrawCurve的用法小结》本文主要介绍了C#中DrawCurve的用法小结,通常用于绘制一条平滑的曲线通过一系列给定的点,具有一定的参考价值,感兴趣的可以了解一下... 目录1. 如何使用 DrawCurve 方法(不带弯曲程度)2. 如何使用 DrawCurve 方法(带弯曲程度)3.使用Dr

基于Python和MoviePy实现照片管理和视频合成工具

《基于Python和MoviePy实现照片管理和视频合成工具》在这篇博客中,我们将详细剖析一个基于Python的图形界面应用程序,该程序使用wxPython构建用户界面,并结合MoviePy、Pill... 目录引言项目概述代码结构分析1. 导入和依赖2. 主类:PhotoManager初始化方法:__in

使用C#代码在PDF文档中添加、删除和替换图片

《使用C#代码在PDF文档中添加、删除和替换图片》在当今数字化文档处理场景中,动态操作PDF文档中的图像已成为企业级应用开发的核心需求之一,本文将介绍如何在.NET平台使用C#代码在PDF文档中添加、... 目录引言用C#添加图片到PDF文档用C#删除PDF文档中的图片用C#替换PDF文档中的图片引言在当