public static void Execute() { // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example) // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config")); // Initialize Configuration object Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"), System.Configuration.ConfigurationManager.AppSettings.Get("Password")); // Initialize SMSClient using the Configuration object SMSClient smsClient = new SMSClient(configuration); SMSRequest smsRequest = new SMSRequest(senderAddress, message, recipientAddress); smsRequest.Language = new Language(LanguageCode.Default); // smsRequest.Language = new Language(LanguageCode.Turkish, true, false); smsClient.SmsMessagingClient.SendSMSAsync(smsRequest, (sendMessageResult, e) => { if (e == null) { Console.WriteLine(sendMessageResult); } else { Console.WriteLine(e.Message); } }); }
public static void Execute() { // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example) // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config")); // example:initialize-sms-client Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"), System.Configuration.ConfigurationManager.AppSettings.Get("Password")); SMSClient smsClient = new SMSClient(configuration); // ---------------------------------------------------------------------------------------------------- // example:prepare-message-without-notify-url SMSRequest smsRequest = new SMSRequest(senderAddress, message, recipientAddress); // ---------------------------------------------------------------------------------------------------- // example:send-message // Store request id because we can later query for the delivery status with it: SendMessageResult sendMessageResult = smsClient.SmsMessagingClient.SendSMS(smsRequest); // ---------------------------------------------------------------------------------------------------- // Few seconds later we can check for the sending status System.Threading.Thread.Sleep(10000); // example:query-for-delivery-status DeliveryInfoList deliveryInfoList = smsClient.SmsMessagingClient.QueryDeliveryStatus(senderAddress, sendMessageResult.ClientCorrelator); string deliveryStatus = deliveryInfoList.DeliveryInfos[0].DeliveryStatus; // ---------------------------------------------------------------------------------------------------- Console.WriteLine(deliveryStatus); }
public static void Execute() { // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example) // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config")); // Initialize Configuration object Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"), System.Configuration.ConfigurationManager.AppSettings.Get("Password")); // Initialize SMSClient using the Configuration object SMSClient smsClient = new SMSClient(configuration); string[] address = new string[2]; address[0] = recipientAddress; address[1] = recipientAddress; SMSRequest smsRequest = new SMSRequest(senderAddress, message, address); SendMessageResult sendMessageResult = smsClient.SmsMessagingClient.SendSMS(smsRequest); Console.WriteLine(sendMessageResult); }
public static void Execute() { // Configure in the 'app.config' which Logger levels are enabled(all levels are enabled in the example) // Check http://logging.apache.org/log4net/release/manual/configuration.html for more informations about the log4net configuration XmlConfigurator.Configure(new FileInfo("OneApiExamples.exe.config")); // Initialize Configuration object Configuration configuration = new Configuration(System.Configuration.ConfigurationManager.AppSettings.Get("Username"), System.Configuration.ConfigurationManager.AppSettings.Get("Password")); // Initialize SMSClient using the Configuration object SMSClient smsClient = new SMSClient(configuration); // Add listener(start push server and wait for the 'Delivery Info Notifications') smsClient.SmsMessagingClient.AddPushDeliveryStatusNotificationsListener(new DeliveryStatusNotificationsListener((deliveryInfoNotification) => { // Handle pushed 'Delivery Info Notification' if (deliveryInfoNotification != null) { string deliveryStatus = deliveryInfoNotification.DeliveryInfo.DeliveryStatus; Console.WriteLine(deliveryStatus); } })); // example:prepare-message-with-notify-url SMSRequest smsRequest = new SMSRequest(senderAddress, message, recipientAddress); // The url where the delivery notification will be pushed: smsRequest.NotifyURL = notifyUrl; // ---------------------------------------------------------------------------------------------------- // Send SMS smsClient.SmsMessagingClient.SendSMS(smsRequest); // Wait 30 seconds for 'Delivery Info Notification' push-es before closing the server connection System.Threading.Thread.Sleep(30000); // Remove 'Delivery Info Notifications' push listeners and stop the server smsClient.SmsMessagingClient.RemovePushDeliveryStatusNotificationsListeners(); }
/// <summary> /// Send an SMS asynchronously over OneAPI to one or more mobile terminals using the customized 'SMS' object </summary> /// <param name="sms"> (mandatory) object containing data needed to be filled in order to send the SMS </param> /// <param name="callback"> (mandatory) method to call after receiving sent SMS response </param> public void SendSMSAsync(SMSRequest smsRequest, System.Action<SendMessageResult, RequestException> callback) { StringBuilder urlBuilder = new StringBuilder(SMS_MESSAGING_OUTBOUND_URL_BASE).Append("/"); urlBuilder.Append(HttpUtility.UrlEncode(smsRequest.SenderAddress)); urlBuilder.Append("/requests"); RequestData requestData = new RequestData(urlBuilder.ToString(), Method.POST, null, smsRequest); requestData.ContentType = RequestData.JSON_CONTENT_TYPE; ExecuteMethodAsync<SendMessageResult>(requestData, callback); }
//*************************SMSMessagingClientImpl public****************************************************************************************************************************************************** /// <summary> /// Send an SMS over OneAPI to one or more mobile terminals using the customized 'SMS' object </summary> /// <param name="sms"> (mandatory) object containing data needed to be filled in order to send the SMS </param> /// <returns> SendMessageResult </returns> public SendMessageResult SendSMS(SMSRequest smsRequest) { StringBuilder urlBuilder = new StringBuilder(SMS_MESSAGING_OUTBOUND_URL_BASE).Append("/"); urlBuilder.Append(HttpUtility.UrlEncode(smsRequest.SenderAddress)); urlBuilder.Append("/requests"); RequestData requestData = new RequestData(urlBuilder.ToString(), Method.POST, null, smsRequest); requestData.ContentType = RequestData.JSON_CONTENT_TYPE; return ExecuteMethod<SendMessageResult>(requestData); }