public void GivenMyFromMobileNumber(String senderMobileNumber)
        {
            SendSMSRequest smsRequest = new SendSMSRequest();

            smsRequest.Sender = senderMobileNumber;
            this.ScenarioContext["SendSMSRequest"] = smsRequest;
        }
Example #2
0
        public SendSMSResponse SendSMS(SendSMSRequest request)
        {
            try
            {
                var destination = request.Message.Destination;
                var message     = request.Message.Message;

                var req = new RestRequest("https://api4.apidaze.io/f0b4155d/sms/send")
                {
                    RequestFormat = DataFormat.Json
                };

                req.AddParameter("api_secret", _ApiSecretKey);
                req.AddParameter("number", $"00{destination}");
                req.AddParameter("subject", "A Message From SOAP Service");
                req.AddParameter("body", message);

                var client = new RestClient();

                var response = client.Post(req);

                if (!response.IsSuccessful)
                {
                    throw new Exception("Request unsuccessful");
                }

                return(new SendSMSResponse {
                    Response = $"message sent to {destination}"
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #3
0
        public async Task <IActionResult> SendSMS([FromBody] SendSMSRequest sendSMSRequest,
                                                  CancellationToken cancellationToken)
        {
            // Reject password tokens
            if (ClaimsHelper.IsPasswordToken(this.User))
            {
                return(this.Forbid());
            }

            Guid messageId = sendSMSRequest.MessageId.HasValue ? sendSMSRequest.MessageId.Value : Guid.NewGuid();

            // Create the command
            BusinessLogic.Requests.SendSMSRequest request = BusinessLogic.Requests.SendSMSRequest.Create(sendSMSRequest.ConnectionIdentifier,
                                                                                                         messageId,
                                                                                                         sendSMSRequest.Sender,
                                                                                                         sendSMSRequest.Destination,
                                                                                                         sendSMSRequest.Message);

            // Route the command
            await this.Mediator.Send(request, cancellationToken);

            // return the result
            return(this.Created($"{SMSController.ControllerRoute}/{messageId}",
                                new SendSMSResponse()
            {
                MessageId = messageId
            }));
        }
Example #4
0
        public async Task <IActionResult> Index()
        {
            SendSMSRequest req = new SendSMSRequest
            {
                PhoneNum = "189189189",
                Msg      = "hello world!"
            };
            string jsonReq = JsonConvert.SerializeObject(req);

            using (var http = new HttpClient())
                using (var content = new StringContent(jsonReq, Encoding.UTF8, "application/json"))
                {
                    http.DefaultRequestHeaders.Authorization = AuthenticationHeaderValue.Parse(LoginController.Token);
                    var resp = await http.PostAsync("http://127.0.0.1:5000/MsgService/SMS/Send_MI", content);

                    if (resp.StatusCode != System.Net.HttpStatusCode.OK)
                    {
                        return(Content("登录成功"));
                    }
                    else
                    {
                        return(Content("登录失败"));
                    }
                }
        }
Example #5
0
        public async Task <bool> SendSMS(SendSMSRequest request)
        {
            logger.Write($"Sending SMS to {request.Nr}");
            var result = await notificationServiceV3.SendSMS(request);

            logger.Write($"SMS to {request.Nr} sent with result {result}");
            return(result);
        }
Example #6
0
 public async Task <SendSMSResponse> SendSMS(SendSMSRequest request, CancellationToken cancellationToken)
 {
     return(new SendSMSResponse
     {
         ApiStatusCode = HttpStatusCode.OK,
         MessageId = "messageid",
         Status = "status"
     });
 }
Example #7
0
        public bool SendSMS(SendSMSRequest smsRequest)
        {
            if (smsRequest == null)
            {
                throw new ArgumentNullException(nameof(smsRequest), "Must not be null");
            }

            return(notificationRepository.SendSMS(smsRequest) > 0);
        }
Example #8
0
        public async Task <IActionResult> PostSMS([FromBody] SendSMSRequest request, CancellationToken cancellationToken)
        {
            Logger.LogInformation(JsonConvert.SerializeObject(request));

            SendSMSCommand command = SendSMSCommand.Create(request);

            await this.CommandRouter.Route(command, cancellationToken);

            return(this.Ok(command.Response));
        }
Example #9
0
        public Task <bool> SendSMS(SendSMSRequest request)
        {
            var result = validator.Validate(request);

            if (!result)
            {
                throw new ArgumentException(nameof(request));
            }
            return(notificationServiceV3.SendSMS(request));
        }
Example #10
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="request"></param>
        public SendSMSResponse SendSMS(SendSMSRequest request)
        {
            string product         = "Dysmsapi";                       //短信API产品名称
            string domain          = "dysmsapi.aliyuncs.com";          //短信API产品域名
            string accessKeyId     = "LTAIOMPsjtzrkrgC";               //你的accessKeyId
            string accessKeySecret = "y4umqrQMKR29NJWoUzMMxuOcCTaEK9"; //你的accessKeySecret

            var cacheProvider = ClientProxy.GetInstance <IRedisProvider>();

            return(cacheProvider.Get <SendSMSResponse>(request.SMSCacheKey, () => {
                IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", accessKeyId, accessKeySecret);
                DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
                IAcsClient acsClient = new DefaultAcsClient(profile);
                SendSmsRequest sendSmsRequest = new SendSmsRequest();
                //必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为20个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
                sendSmsRequest.PhoneNumbers = request.PhoneNumber;
                //必填:短信签名-可在短信控制台中找到
                sendSmsRequest.SignName = "千年教育";
                //必填:短信模板-可在短信控制台中找到
                sendSmsRequest.TemplateCode = "SMS_112465567";
                //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
                var templateParam = new
                {
                    code = request.Rand
                };
                sendSmsRequest.TemplateParam = templateParam.ToJson2();
                //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
                //request.OutId = "21212121211";
                //请求失败这里会抛ClientException异常
                SendSmsResponse sendSmsResponse = acsClient.GetAcsResponse(sendSmsRequest);
                if (sendSmsResponse.Code != null && sendSmsResponse.Code.Equals("OK"))
                {
                    Using <ISMS>().Insert(new BsSMS()
                    {
                        PhoneNumber = request.PhoneNumber,
                        Content = string.Format("您的短信验证码是{0}。若非本人发送,请忽略此短信。本条短信免费。", request.Rand),
                        Priority = 10,
                        FailureTimes = 0,
                        Status = 1,
                        CreatedBy = 1,
                        CreatedDate = DateTime.Now
                    });
                    return new SendSMSResponse()
                    {
                        PhoneNumber = request.PhoneNumber,
                        Rand = request.Rand,
                        SendTime = DateTime.Now
                    };
                }
                else
                {
                    return new SendSMSResponse();
                }
            }, request.catchTime));
        }
Example #11
0
        private void SendSms(string verificationCode, string mobile)
        {
            SendSMSRequest smsRequest = new SendSMSRequest
            {
                MobileNo       = mobile,
                TemplateCode   = "wathi00001",
                TemplateParams = new string[] { verificationCode },
                RefID          = Guid.NewGuid().ToString(),
            };

            SMSEmailNotificationService.Obj.SendSMS(smsRequest);
        }
Example #12
0
        public void MessagingRequestHandler_SendSMSRequest_IsHandled()
        {
            Mock <IMessagingDomainService> messagingDomainService = new Mock <IMessagingDomainService>();
            MessagingRequestHandler        handler = new MessagingRequestHandler(messagingDomainService.Object);

            SendSMSRequest command = TestData.SendSMSRequest;

            Should.NotThrow(async() =>
            {
                await handler.Handle(command, CancellationToken.None);
            });
        }
        public async Task <String> Handle(SendSMSRequest request,
                                          CancellationToken cancellationToken)
        {
            await this.MessagingDomainService.SendSMSMessage(request.ConnectionIdentifier,
                                                             request.MessageId,
                                                             request.Sender,
                                                             request.Destination,
                                                             request.Message,
                                                             cancellationToken);

            return(string.Empty);
        }
        public async Task <IActionResult> SendMessage([FromBody] SendSMSRequest Request)
        {
            try
            {
                CommunicationResponse Response = await _mediator.Send(Request);

                return(Ok(Response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Example #15
0
        public static void SendSMS(SendSMSRequest request)
        {
            // Setup our request
            var webserviceRequest = new Common.Api.ExigoWebService.SendSmsRequest
            {
                CustomerID = request.CustomerID,
                Message    = request.Message
            };
            if (request.Phone.IsNotNullOrEmpty()) webserviceRequest.Phone = request.Phone;

            // Send the request to the web service
            var response = Exigo.WebService().SendSms(webserviceRequest);
        }
Example #16
0
        public async Task <bool> SendSMS(SendSMSRequest request)
        {
            var result = cache.Get <string>("phoneNr");

            if (result != null && result == request.Nr)
            {
                return(true);
            }
            var sendResult = await notificationServiceV3.SendSMS(request);

            cache.Add("phoneNr", request.Nr);
            return(sendResult);
        }
Example #17
0
        public MessageOutput SendSMS(MessageInput messageInput)
        {
            //var basicHttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.None)
            //{
            //    Name = "BasicHttpBinding_IBlogService",
            //    MaxReceivedMessageSize = 2147483646,
            //    MaxBufferSize = 2147483646,
            //    MaxBufferPoolSize = 2147483646,
            //    ReaderQuotas = new XmlDictionaryReaderQuotas()
            //    {
            //        MaxArrayLength = 2147483646,
            //        MaxStringContentLength = 5242880
            //    },
            //    SendTimeout = new TimeSpan(0, 5, 0),
            //    CloseTimeout = new TimeSpan(0, 5, 0),
            //    Security = new BasicHttpSecurity
            //    {
            //        Mode = BasicHttpSecurityMode.None,
            //        Transport = new HttpTransportSecurity
            //        {
            //            ClientCredentialType = HttpClientCredentialType.None
            //        }
            //    }
            //};

            //var endpointAddress = new EndpointAddress("http://localhost:8000");

            var client = new NotificationServiceClient();

            client.OpenAsync();

            var obj = new SendSMSRequest()
            {
                ServiceToken = new ServiceToken
                {
                    Token = _Token
                },
                Message = new SMS()
                {
                    Destination = messageInput.Destination,
                    Message     = messageInput.Message
                }
            };

            var reply = client.SMSAsync(obj.ServiceToken, obj.Message).Result;

            client.CloseAsync();

            return(_NotificationMapping.MapNotificationOutput(reply));
        }
        public void SendSMSRequest_CanBeCreated_IsCreated()
        {
            SendSMSRequest request = SendSMSRequest.Create(TestData.ConnectionIdentifier,
                                                           TestData.MessageId,
                                                           TestData.Sender,
                                                           TestData.Destination,
                                                           TestData.Message);

            request.ShouldNotBeNull();
            request.ConnectionIdentifier.ShouldBe(TestData.ConnectionIdentifier);
            request.MessageId.ShouldBe(TestData.MessageId);
            request.Sender.ShouldBe(TestData.Sender);
            request.Destination.ShouldBe(TestData.Destination);
            request.Message.ShouldBe(TestData.Message);
        }
Example #19
0
        static void Main(string[] args)
        {
            const string accessKeyId     = "AAAA"; // 用户的Access Key ID
            const string secretAccessKey = "BBBB"; // 用户的Secret Access Key

            var config = new SMSBceClientConfiguration(accessKeyId, secretAccessKey);
            var client = new SMSClient(config);

            var req = new SendSMSRequest();

            req.Mobile      = "13xxxxxxx";
            req.SignatureId = "sms-sign-xxxx";
            req.Template    = "sms-tmpl-xxxxx";
            req.ContentVar.Add("code", "8888"); //模板变量
            client.SendSMS(req);
        }
Example #20
0
        public SendSMSResponse SendSMS(SendSMSRequest request)
        {
            CheckNotNull(request, "request should NOT be null.");

            var internalRequest = this.CreateInternalRequest(BceConstants.HttpMethod.Post, request);

            internalRequest.Content = request.GetConentStream();
            return(internalRequest.Config.RetryPolicy.Execute <SendSMSResponse>(attempt =>
            {
                var httpWebResponse = this.httpClient.Execute(internalRequest);
                using (httpWebResponse)
                {
                    return ToObject <SendSMSResponse>(httpWebResponse);
                }
            }));
        }
        /// <summary>
        /// Handles the specific domain event.
        /// </summary>
        /// <param name="domainEvent">The domain event.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        private async Task HandleSpecificDomainEvent(VoucherIssuedEvent domainEvent,
                                                     CancellationToken cancellationToken)
        {
            // Get the voucher aggregate
            VoucherAggregate voucherAggregate = await this.VoucherAggregateRepository.GetLatestVersion(domainEvent.AggregateId, cancellationToken);

            Voucher voucherModel = voucherAggregate.GetVoucher();

            this.TokenResponse = await this.GetToken(cancellationToken);

            if (string.IsNullOrEmpty(voucherModel.RecipientEmail) == false)
            {
                String message = await this.GetEmailVoucherMessage(voucherModel, cancellationToken);

                SendEmailRequest request = new SendEmailRequest
                {
                    Body = message,
                    ConnectionIdentifier = domainEvent.EstateId,
                    FromAddress          = "*****@*****.**",                   // TODO: lookup from config
                    IsHtml      = true,
                    MessageId   = domainEvent.EventId,
                    Subject     = "Voucher Issue",
                    ToAddresses = new List <String>
                    {
                        voucherModel.RecipientEmail
                    }
                };

                await this.MessagingServiceClient.SendEmail(this.TokenResponse.AccessToken, request, cancellationToken);
            }

            if (String.IsNullOrEmpty(voucherModel.RecipientMobile) == false)
            {
                String message = await this.GetSMSVoucherMessage(voucherModel, cancellationToken);

                SendSMSRequest request = new SendSMSRequest
                {
                    ConnectionIdentifier = domainEvent.EstateId,
                    Destination          = domainEvent.RecipientMobile,
                    Message   = message,
                    MessageId = domainEvent.EventId,
                    Sender    = "Your Voucher"
                };

                await this.MessagingServiceClient.SendSMS(this.TokenResponse.AccessToken, request, cancellationToken);
            }
        }
Example #22
0
    public tempuri.org.ArrayOfLong SendSMS(string username, string password, tempuri.org.ArrayOfString senderNumbers, tempuri.org.ArrayOfString recipientNumbers, tempuri.org.ArrayOfString messageBodies, tempuri.org.ArrayOfString sendDate, tempuri.org.ArrayOfInt messageClasses, tempuri.org.ArrayOfLong checkingMessageIds)
    {
        SendSMSRequest inValue = new SendSMSRequest();

        inValue.Body                    = new SendSMSRequestBody();
        inValue.Body.username           = username;
        inValue.Body.password           = password;
        inValue.Body.senderNumbers      = senderNumbers;
        inValue.Body.recipientNumbers   = recipientNumbers;
        inValue.Body.messageBodies      = messageBodies;
        inValue.Body.sendDate           = sendDate;
        inValue.Body.messageClasses     = messageClasses;
        inValue.Body.checkingMessageIds = checkingMessageIds;
        SendSMSResponse retVal = ((IV2Soap)(this)).SendSMS(inValue);

        return(retVal.Body.SendSMSResult);
    }
Example #23
0
        private async Task SendSMS(TableRow tableRow)
        {
            String sender      = SpecflowTableHelper.GetStringRowValue(tableRow, "Sender");
            String destination = SpecflowTableHelper.GetStringRowValue(tableRow, "Destination");
            String message     = SpecflowTableHelper.GetStringRowValue(tableRow, "Message");

            SendSMSRequest request = new SendSMSRequest
            {
                ConnectionIdentifier = Guid.NewGuid(),
                Sender      = sender,
                Destination = destination,
                Message     = message
            };

            SendSMSResponse sendEmailResponse = await this.TestingContext.DockerHelper.MessagingServiceClient.SendSMS(this.TestingContext.AccessToken, request, CancellationToken.None).ConfigureAwait(false);

            sendEmailResponse.MessageId.ShouldNotBe(Guid.Empty);
        }
Example #24
0
        public static void SendSMS(SendSMSRequest request)
        {
            // Setup our request
            var webserviceRequest = new Common.Api.ExigoWebService.SendSmsRequest
            {
                CustomerID = request.CustomerID,
                Message    = request.Message
            };

            if (request.Phone.IsNotNullOrEmpty())
            {
                webserviceRequest.Phone = request.Phone;
            }


            // Send the request to the web service
            var response = Exigo.WebService().SendSms(webserviceRequest);
        }
Example #25
0
        static void Main(string[] args)
        {
            var config = new Configuration();

            config.BasePath = "https://tapi.telstra.com/v2";
            var apiInstance  = new AuthenticationApi(config);
            var clientId     = Environment.GetEnvironmentVariable("CLIENT_ID");     // string |
            var clientSecret = Environment.GetEnvironmentVariable("CLIENT_SECRET"); // string |
            var grantType    = "client_credentials";                                // string |  (default to "client_credentials")
            var scope        = "NSMS";                                              // string | NSMS (optional)

            try
            {
                // Generate OAuth2 token
                OAuthResponse result = apiInstance.AuthToken(clientId, clientSecret, grantType, scope);
                Console.WriteLine("Token acquired!");
                config.AccessToken = result.AccessToken;

                var provisioningInstance = new ProvisioningApi(config);
                var body = new ProvisionNumberRequest(30);
                ProvisionNumberResponse provisioningResult = provisioningInstance.CreateSubscription(body);
                Console.WriteLine("Number provisioned!");

                var smsApiInstance = new MessagingApi(config);
                var payload        = new SendSMSRequest(
                    Environment.GetEnvironmentVariable("PHONE_NO"),
                    "Test C# SDK",
                    Environment.GetEnvironmentVariable("FROM_ALIAS"));

                MessageSentResponseSms smsResult = smsApiInstance.SendSMS(payload);
                Console.WriteLine("Message sent");
            }
            catch (ApiException e)
            {
                Console.WriteLine("Exception when calling AuthenticationApi.AuthToken: " + e.Message);
                Console.WriteLine("Status Code: " + e.ErrorCode);
                Console.WriteLine(e.StackTrace);
                throw;
            }
        }
        /// <summary>
        /// Sends the SMS.
        /// </summary>
        /// <param name="accessToken">The access token.</param>
        /// <param name="sendSMSRequest">The send SMS request.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns></returns>
        public async Task <SendSMSResponse> SendSMS(String accessToken,
                                                    SendSMSRequest sendSMSRequest,
                                                    CancellationToken cancellationToken)
        {
            SendSMSResponse response = null;

            String requestUri = this.BuildRequestUrl("/api/sms/");

            try
            {
                String requestSerialised = JsonConvert.SerializeObject(sendSMSRequest);

                StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json");

                // Add the access token to the client headers
                this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

                // Make the Http Call here
                HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken);

                // Process the response
                String content = await this.HandleResponse(httpResponse, cancellationToken);

                // call was successful so now deserialise the body to the response object
                response = JsonConvert.DeserializeObject <SendSMSResponse>(content);
            }
            catch (Exception ex)
            {
                // An exception has occurred, add some additional information to the message
                Exception exception = new Exception("Error sending sms message.", ex);

                throw exception;
            }

            return(response);
        }
Example #27
0
        public async Task <bool> SendSMS(SendSMSRequest request)
        {
            _loggerService.LogInformation("SendSMS(SendSMSRequest request) - START", request);

            // Normally create a mapper here - in case sms provider requires diff info. (^_^)

            var clickaTellRequest = new ShortMessage()
            {
                CellNumberSendFrom = request.CellNumber,
                CellNumberSendTo   = request.SendTo,
                Message            = request.Message
            };

            // Normally have a gateway here in case sms provider changes (^_^)

            // No need to try catch, unless there's specific error type we want to look for.
            // Exception handling is done by middleware.

            var success = await _smsRepo.SendSMSClickaTell(clickaTellRequest);

            _loggerService.LogInformation("SendSMS(SendSMSRequest request) - END", request);

            return(success);
        }
Example #28
0
 SendSMSResponse IV2Soap.SendSMS(SendSMSRequest request)
 {
     return(base.Channel.SendSMS(request));
 }
Example #29
0
        public async Task <TwoFaMasterViewModel> AddOtpAsync(int UserId, string Email = null, string Mobile = null)
        {
            var checkotp = await GetOtpData(UserId);

            string OtpValue = string.Empty;

            if (checkotp != null)
            {
                UpdateOtp(checkotp.Id);
            }
            OtpValue = _userService.GenerateRandomOTP().ToString();
            int Regtypeid = 0;

            if (!String.IsNullOrEmpty(Email))
            {
                Regtypeid = await _registerTypeService.GetRegisterId(Core.Enums.enRegisterType.Email);
            }
            else if (!String.IsNullOrEmpty(Mobile))
            {
                Regtypeid = await _registerTypeService.GetRegisterId(Core.Enums.enRegisterType.Mobile);
            }

            var currentotp = new TwoFAmaster
            {
                UserId      = UserId,
                RegTypeId   = Regtypeid,
                OTP         = OtpValue,
                CreatedTime = DateTime.UtcNow,
                ExpirTime   = DateTime.UtcNow.AddHours(2),
                Status      = 0,
                CreatedDate = DateTime.Now,
                CreatedBy   = UserId
            };

            _customRepository.Insert(currentotp);
            if (!String.IsNullOrEmpty(Email))
            {
                //var OtpLink = "<a class='btn-primary' href=\"" + OtpValue + "\"> Login with Email Otp = " + OtpValue + " </a>";
                //_logger.LogInformation(3, "User created a new account with password.");

                SendEmailRequest request = new SendEmailRequest();
                request.Recepient = Email;
                request.Subject   = EnResponseMessage.LoginEmailSubject;
                request.Body      = EnResponseMessage.SendMailBody + OtpValue;
                await _mediator.Send(request);
            }
            if (!String.IsNullOrEmpty(Mobile))
            {
                SendSMSRequest request = new SendSMSRequest();
                request.MobileNo = Convert.ToInt64(Mobile);
                request.Message  = EnResponseMessage.SendMailBody + OtpValue;
                await _mediator.Send(request);
            }
            TwoFaMasterViewModel model = new TwoFaMasterViewModel();

            if (currentotp != null)
            {
                model.UserId      = currentotp.UserId;
                model.RegTypeId   = currentotp.RegTypeId;
                model.OTP         = currentotp.OTP;
                model.CreatedTime = currentotp.CreatedTime;
                model.ExpirTime   = currentotp.ExpirTime;
                model.Status      = currentotp.Status;
                model.Id          = currentotp.Id;
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #30
0
 public void Send_HW(SendSMSRequest model)
 {
     Console.WriteLine($"通过华为短信接口向{model.PhoneNum}发送短信{model.Msg}");
 }
 public string GetCreditOfSmsPanel()
 {
     SendSMSRequest s = new SendSMSRequest();
     smsserverPortTypeClient sms = new smsserverPortTypeClient();
     return sms.GetCredit(SmsPanelUserName, SmsPanelPassWord);
 }
Example #32
0
 public IEnumerable <string> Send_LX2(SendSMSRequest model)
 {
     Console.WriteLine($"通过联想短信接口向{model.PhoneNum}发送短信{model.Msg}");
     return(new[] { "Hello", "World" });
 }