Пример #1
0
        /// <summary>
        /// 发送短信推广类
        /// </summary>
        public void PromotionSmsPublish()
        {
            // 发送手机号码 号码格式 (+)(国家码)(手机号码)
            List <string> endpoints = new List <string>
            {
                "86136*****87"
            };
            // 设置请求对象
            PromotionSmsPublishRequest request = new PromotionSmsPublishRequest
            {
                Endpoints = endpoints,
                // 短信签名必填,需要在消息通知服务的自助页面申请签名,申请办理时间约2天
                SignId        = "47f86cf7c9a7449d98ee61cf193a1060",
                SmsTemplateId = "bfda25c6406e42ddabad74b4a20f6d05"
            };

            try
            {
                // 发送请求并返回响应
                PromotionSmsPublishResponse      response = smnClient.SendRequest(request);
                List <PromotionSmsPublishResult> results  = response.Result;
                foreach (PromotionSmsPublishResult result in results)
                {
                    Console.WriteLine("messageId={0}, endpoint={1}, code={2}, message={3}",
                                      result.MessageId, result.Endpoint, result.Code, result.Message);
                }
                Console.ReadLine();
            }
            catch (Exception e)
            {
                // 处理异常
                Console.WriteLine("{0}", e.Message);
                Console.ReadLine();
            }
        }
Пример #2
0
        /// <summary>
        /// 发送短信推广类
        /// </summary>
        public void PromotionSmsPublish()
        {
            // 发送手机号码 号码格式 (+)(国家码)(手机号码)
            List <string> endpoints = new List <string>
            {
                "86136*****87"
            };
            // 设置请求对象
            PromotionSmsPublishRequest request = new PromotionSmsPublishRequest
            {
                Endpoints = endpoints,
                // 短信签名必填,需要在消息通知服务的自助页面申请签名,申请办理时间约2天
                SignId        = "47f86cf7c9a7449d98ee61cf193a1060",
                SmsTemplateId = "0d98ad57c4e64f1ca8b76c1d4c9b221a",
                //// 可选字段,扩展码,短信状态通知时会返回
                //ExtendCode = "extendCodeTest4",
                //// 可选字段,短信发送方号码的扩展字段,仅限可自定义扩展的签名使用
                //ExtendSrcId = "123"
            };

            try
            {
                // 发送请求并返回响应
                PromotionSmsPublishResponse      response = smnClient.SendRequest(request);
                List <PromotionSmsPublishResult> results  = response.Result;
                foreach (PromotionSmsPublishResult result in results)
                {
                    Console.WriteLine("messageId={0}, endpoint={1}, code={2}, message={3}",
                                      result.MessageId, result.Endpoint, result.Code, result.Message);
                }
                Console.ReadLine();
            }
            catch (Exception e)
            {
                // 处理异常
                Console.WriteLine("{0}", e.Message);
                Console.ReadLine();
            }
        }