public void testSmsSend() { SmsSendRequest request = new SmsSendRequest(); request.Iccid = "89860401101730528433"; request.Text = "C#发送短信"; SimbossResponse <String> response = client.Excute <String>(request); log.WriteLine(response.ToString()); }
public TokenService(TokenContext tokenContext, UserHospitalContext userHospitalContext, UserClientContext userClientContext, SmsSendRequest smsSendRequest) { _tokenContext = tokenContext; _userHospitalContext = userHospitalContext; _userClientContext = userClientContext; _smsSendRequest = smsSendRequest; }
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)); }
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); }
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); }
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); }
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); }
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); } }
/// <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)))); }
/// <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); }
/// <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); }