旅游行业怎么利用C#接口发送短信

news2024/9/20 1:01:36

旅游企业一般拥有众多的分支机构,同时各地分支机构又有众多下属分散在当地各区的旅游营业报名点,以前传统的解决方案是采用专线、MODEM拔号等方式,专线的成本很高,MODEM拔号更费时,且长途拔号互联成本在多点情况下费用也不低。相反的是,群发短信业务不仅费用低,且效率好。

 支持免费试用乐讯通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";

        //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();
        }

    }
}

 

服务信息:发布旅游信息,吸引客户,这种方式费用低,效率好。景区宣传:可对旅游景区(点)或旅游公司新推出的旅游路线进行描述,通过短信发送到潜在顾客的手机上,实现对旅游产品及服务的跨区域、跨时空宣传。

订房/订票公司、旅行社可以通过短信通向客户发送消费积分、节日祝福、生日祝贺等,实现低成本有效的客户管理,加强客情沟通、提高客户满意度,提高营业收入。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2070553.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

scikit-learn特征抽取

为什么需要特征工程 数据和特征决定了机器学习的上限&#xff0c;而模型和算法只是逼近这个上限而已 什么是特征工程 特征工程是使用专业背景知识和技巧处理数据&#xff0c;使得特征能在机器学习算法上发挥更好的作用的过程 意义&#xff1a;会直接影响机器学习的效果 特征…

Type-C无线麦克风方案

在数字化浪潮的推动下&#xff0c;音频设备正经历着前所未有的变革。从传统的有线麦克风到如今的蓝牙无线麦克风&#xff0c;每一次技术的飞跃都极大地丰富了我们的音频体验。而今&#xff0c;随着Type-C接口的普及与技术的不断成熟&#xff0c;Type-C无线麦克风正悄然成为音频…

数据结构----红黑树

小编会一直更新数据结构相关方面的知识&#xff0c;使用的语言是Java&#xff0c;但是其中的逻辑和思路并不影响&#xff0c;如果感兴趣可以关注合集。 希望大家看完之后可以自己去手敲实现一遍&#xff0c;同时在最后我也列出一些基本和经典的题目&#xff0c;可以尝试做一下。…

DRF——Filter条件搜索模块

文章目录 条件搜索自定义Filter第三方Filter内置Filter 条件搜索 如果某个API需要传递一些条件进行搜索&#xff0c;其实就在是URL后面通过GET传参即可&#xff0c;例如&#xff1a; /api/users?age19&category12在drf中也有相应组件可以支持条件搜索。 自定义Filter …

学习2d直线拟合-2

参考文章 直线拟合算法&#xff08;续&#xff1a;加权最小二乘&#xff09;_加权拟合直线法-CSDN博客 对比了参考文中和opencv中的直线拟合权重&#xff0c;不知道理解的对不对&#xff0c;前者是权重平方&#xff0c;后者没有平方

迷雾大陆辅助:VMOS云手机助力升级装备系统秘籍!

在《迷雾大陆》的广阔世界中&#xff0c;装备的选择和获取对于每一位冒险者来说都是至关重要的。为了让玩家能够更轻松地管理装备并在冒险中获得更高的效率&#xff0c;VMOS云手机提供了专属定制版云手机&#xff0c;内置游戏安装包&#xff0c;不需要重新下载安装游戏。VMOS云…

【VectorNet】vectornet网络学习笔记

文章目录 前言(vectornet算法流程)(向量表示)(图构建)(子图构建)(全局图构建)(解码器: 轨迹预测)(辅助研究)(损失函数)(实验)(问题厘清) VectorNet Overview 前言 论文: https://arxiv.org/pdf/2005.04259代码: https://github.com/xk-huang/yet-another-vectornet年份: 2020.…

Hadoop联邦模式搭建

在Hadoop架构中提供了三类搭建方式&#xff0c;第一类是给测试或开发人员使用的伪分布式或单NN节点搭建方式&#xff0c;第二类是用来商用化并解决NN单点故障的HA搭建方式&#xff0c;第三类就是这里要说的联邦模式&#xff0c;它本身也是一种供给商用的模式&#xff0c;但是它…

【Apache Doris】周FAQ集锦:第 19 期

【Apache Doris】周FAQ集锦&#xff1a;第 19 期 SQL问题数据操作问题运维常见问题其它问题关于社区 欢迎查阅本周的 Apache Doris 社区 FAQ 栏目&#xff01; 在这个栏目中&#xff0c;每周将筛选社区反馈的热门问题和话题&#xff0c;重点回答并进行深入探讨。旨在为广大用户…

openmediavault 存储安装

1、简介 openmediavault NAS存储&#xff0c;支持linux和windows文件共享&#xff08;文件系统共享&#xff09;&#xff0c;有中文web界面&#xff0c;有filebrowser插件可以web界面管理、下载文件&#xff0c;有FTP插件支持ftp操作&#xff0c;有用户管理&#xff1b;插件丰富…

“七人团裂变风暴:重塑社交电商格局

在当今商业浪潮中&#xff0c;七人共创团购模式以其独特的魅力&#xff0c;正引领着中小型企业走向市场的新高地。这一模式巧妙融合了社交电商的精髓与拼购的乐趣&#xff0c;不仅加速了用户群体的指数级增长&#xff0c;还极大地提升了产品的市场渗透率与品牌影响力。同时&…

TQSDRPI开发板教程:单音回环测试

将我提供的启动文件复制到SD卡中&#xff0c;并插入开发板&#xff0c;插入串口线&#xff0c;启动模式设置为SD卡启动&#xff0c;开启开关。提供的文件在文章末尾。 ​ 查看串口输出内容 ​ 在串口输出的最后有写命令可以使用 ​ 在串口输入如下内容可以对输出的信号进…

计算机毕业设计选题推荐-游戏比赛网上售票系统-Java/Python项目实战

✨作者主页&#xff1a;IT研究室✨ 个人简介&#xff1a;曾从事计算机专业培训教学&#xff0c;擅长Java、Python、微信小程序、Golang、安卓Android等项目实战。接项目定制开发、代码讲解、答辩教学、文档编写、降重等。 ☑文末获取源码☑ 精彩专栏推荐⬇⬇⬇ Java项目 Python…

二叉树的分层遍历、栈的压入弹出序列

本章主要来讲解两个OJ题&#xff0c;针对每个OJ题我分三部分来解决&#xff0c;分别是题目解析&#xff08;主要弄清楚题目要求我们解决什么问题&#xff09;&#xff0c;算法原理&#xff0c;代码编写&#xff0c;接下来让我们进入正题。 一、二叉树的分层遍历 1.题目解析 题…

VSCODE 使用正则表达式匹配替换有规律的行

需求描述 我有类似的文本 count count_l24 count_l32 count count count我需要逐行替换l24,l32所在行&#xff0c;其他行保留。 步骤 替换的时候找到正则表达式的选项 输入: ^._l.$ 替换为空行就行.

攻防世界-web题型-7星难度汇总-个人wp

Web_php_wrong_nginx_config 这个题目nginx配置错误 随便输入显示网站还没建设好。。。 先信息收集一下 换了个无敌好看的终端 没想到7星了还玩这些。。。 看了admin的页面需要先登录 现在的问题是如果读取到这个文件 这个hack的文件也没有东西 到此就不知道了&#xff0…

【二叉树---堆的C语言实现】

1.树的概念与结构 树是一种非线性的数据结构&#xff0c;它n&#xff08;N>0&#xff09;个有限节点组成一个具有层次关系的集合。把它叫做树是因为它看起来像一棵倒挂着的树&#xff0c;也就是说它是根朝上&#xff0c;而叶朝下的。 有一个特殊的节点&#xff0c;称为根节…

【基础算法】位运算

位运算 概念位运算模板模板题 概念 异或&#xff08;x⊕y或x ^ y&#xff09; 高低位交换:https://www.luogu.com.cn/problem/P1100 题意&#xff1a;给定一个32 3232位整数x xx&#xff0c;在二进制下交换其前16 1616位与后16 1616位&#xff0c;输出最终的数。 答案为ans (…

JVM系列--垃圾回收

在C/C这类没有自动垃圾回收机制的语言中&#xff0c;一个对象如果不再使用&#xff0c;需要手动释放&#xff0c;否则就会出现内存泄漏。内存泄漏指的是不再使用的对象在系统中未被回收&#xff0c;内存泄漏的积累可能会导致内存溢出。 在这段代码中&#xff0c;通过死循环不停…

besier打断和升阶,高阶性质

欢迎关注更多精彩 关注我&#xff0c;学习常用算法与数据结构&#xff0c;一题多解&#xff0c;降维打击。 问题描述 对besier曲线在u处打断&#xff0c;生成两条besier曲线对besier曲线升阶处理 bezier高阶性质 求导推导 P ( t ) ∑ i 0 n B i n ( t ) b i \boldsymbol …