示例#1
0
        public void testSmsSend()
        {
            SmsSendRequest request = new SmsSendRequest();

            request.Iccid = "89860401101730528433";
            request.Text  = "C#发送短信";
            SimbossResponse <String> response = client.Excute <String>(request);

            log.WriteLine(response.ToString());
        }
示例#2
0
 public TokenService(TokenContext tokenContext,
                     UserHospitalContext userHospitalContext,
                     UserClientContext userClientContext,
                     SmsSendRequest smsSendRequest)
 {
     _tokenContext        = tokenContext;
     _userHospitalContext = userHospitalContext;
     _userClientContext   = userClientContext;
     _smsSendRequest      = smsSendRequest;
 }
示例#3
0
        public HttpResponseMessage PostSend(SmsSendRequest modal)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            ItemResponse <string> responseBody = new ItemResponse <string>();

            responseBody.Item = _service.Send(modal);
            return(Request.CreateResponse(HttpStatusCode.OK, responseBody));
        }
示例#4
0
        public SmsSendResponse UserGet([FromBody] SmsSendRequest req)
        {
            var rep     = new SmsSendResponse();
            var message = new SmsMessage();

            message.Mobile  = req.Mobile;
            message.Content = "abc";       //¶ÌÐÅÑéÖ¤Âë
            var status = smsService.Send(message);

            if (status)
            {
                rep.Data = message.Content;
            }
            return(rep);
        }
示例#5
0
        public static async Task SendSms(string toNumber, string entryCode)
        {
            var token = await RequestToken(new Uri(AuthorizationServerTokenIssuerUri), ClientId, ScopeUri, ClientSecret);

            var smsSendUri = new Uri(new Uri("https://gateway.kmdlogic.io/sms/v1/"), "subscriptions/x/sms");

            var smsRequest = new SmsSendRequest
            {
                toPhoneNumber           = toNumber,
                body                    = $"Your entry code is {entryCode}",
                providerConfigurationId = _smsProviderConfigId,
                callbackUrl             = string.Empty
            };

            var smsResponse = await PostAsync <SmsSendRequest, SmsSendResponse>(smsSendUri, token, smsRequest);
        }
示例#6
0
        private async Task SendQuickAsync(SendOtpInput input)
        {
            var smsServerUrl = await _systemConfigServices.GetValueAsync(SmsGateway.ServerUrlConfigKey);

            var smsOtpTemplate = await _systemConfigServices.GetValueAsync("SmsOtpTemplate");

            // prepare
            SmsSendRequest smsSendRequest = new SmsSendRequest();

            smsSendRequest.ServerUrl    = smsServerUrl;
            smsSendRequest.MobileNumber = input.Mobile;
            smsSendRequest.Text         = smsOtpTemplate
                                          .Replace("{otp}", input.Otp)
                                          .Replace("{time}", input.Time);
            smsSendRequest.IsUnicode = false;
            await SmsGateway.SendQuick_Send(smsSendRequest);
        }
示例#7
0
        private static async Task Run(AppConfiguration config)
        {
            ValidateConfiguration(config);

            Log.Information("Logic environment is {LogicEnvironmentName}", config.LogicEnvironmentName);
            var logicEnvironment = config.LogicEnvironments.FirstOrDefault(e => e.Name == config.LogicEnvironmentName);

            if (logicEnvironment == null)
            {
                Log.Error("No logic environment named {LogicEnvironmentName}", config.LogicEnvironmentName);
                return;
            }

            Log.Information("Requesting auth token for account ClientID `{LogicAccount}` and subscription `{SubscriptionId}`",
                            config.LogicAccount.ClientId, config.LogicAccount.SubscriptionId);

            var token = await RequestToken(
                logicEnvironment.AuthorizationServerTokenIssuerUri,
                config.LogicAccount.ClientId,
                logicEnvironment.ScopeUri.ToString(),
                config.LogicAccount.ClientSecret);

            Log.Debug("Got access token {@Token}", token);

            var smsSendUri = new Uri(logicEnvironment.ApiRootUri, $"subscriptions/{config.LogicAccount.SubscriptionId}/sms");

            var smsRequest = new SmsSendRequest
            {
                toPhoneNumber           = config.Sms.ToPhoneNumber,
                body                    = config.Sms.SmsBodyText,
                providerConfigurationId = config.Sms.ProviderConfigurationId,
                callbackUrl             = config.Sms.CallbackUrl?.ToString(),
            };

            Log.Information("Sending request {@SmsSendRequest} to {SmsSendUri}", smsRequest, smsSendUri);
            var smsResponse = await PostAsync <SmsSendRequest, SmsSendResponse>(smsSendUri, token, smsRequest);

            Log.Information("Got response {@SmsResponse}", smsResponse);
        }
示例#8
0
        public string Send(SmsSendRequest data)
        {
            try
            {
                TwilioClient.Init(accountsid, authtoken);
                PhoneNumber to   = new PhoneNumber(data.PhoneNumber);
                PhoneNumber from = new PhoneNumber(serverPhoneNumber);

                MessageResource messege = MessageResource.Create(
                    to: to,
                    from: from,
                    body: data.Messege);
                return("Succsess");
            }
            catch (Twilio.Exceptions.ApiException e)
            {
                throw new Exception(e.Message);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
示例#9
0
        /// <summary>
        /// Send a text message request.
        /// </summary>
        /// <exception cref="Com.Nvt.Celman.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="smsSendRequest"></param>
        /// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
        /// <returns>Task of ApiResponse (SmsSendResponse)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <SmsSendResponse> > SmsSendWithHttpInfoAsync(SmsSendRequest smsSendRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            // verify the required parameter 'smsSendRequest' is set
            if (smsSendRequest == null)
            {
                throw new ApiException(400, "Missing required parameter 'smsSendRequest' when calling DefaultApi->SmsSend");
            }

            var    localVarPath         = "/sms/send";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (smsSendRequest != null && smsSendRequest.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(smsSendRequest); // http body (model) parameter
            }
            else
            {
                localVarPostBody = smsSendRequest; // byte array
            }

            // authentication (ApiKeyAuth) required
            if (!String.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("X-Auth-Token")))
            {
                localVarHeaderParams["X-Auth-Token"] = this.Configuration.GetApiKeyWithPrefix("X-Auth-Token");
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType, cancellationToken);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("SmsSend", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <SmsSendResponse>(localVarStatusCode,
                                                     localVarResponse.Headers.ToDictionary(x => x.Name, x => string.Join(",", x.Value)),
                                                     (SmsSendResponse)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(SmsSendResponse))));
        }
示例#10
0
        /// <summary>
        /// Send a text message request.
        /// </summary>
        /// <exception cref="Com.Nvt.Celman.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="smsSendRequest"></param>
        /// <param name="cancellationToken">Cancellation Token to cancel request (optional) </param>
        /// <returns>Task of SmsSendResponse</returns>
        public async System.Threading.Tasks.Task <SmsSendResponse> SmsSendAsync(SmsSendRequest smsSendRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            ApiResponse <SmsSendResponse> localVarResponse = await SmsSendWithHttpInfoAsync(smsSendRequest, cancellationToken);

            return(localVarResponse.Data);
        }
示例#11
0
        /// <summary>
        /// Send a text message request.
        /// </summary>
        /// <exception cref="Com.Nvt.Celman.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="smsSendRequest"></param>
        /// <returns>SmsSendResponse</returns>
        public SmsSendResponse SmsSend(SmsSendRequest smsSendRequest)
        {
            ApiResponse <SmsSendResponse> localVarResponse = SmsSendWithHttpInfo(smsSendRequest);

            return(localVarResponse.Data);
        }