Example #1
0
        public static void SendMessage(string to, string text)
        {
            lock (lockObj)
            {
                if (bearerToken == null)
                {
                    GetBearerToken();
                }
            }


            var client  = new RestClient("https://plus.sent.ly/api/");
            var request = new RestRequest("sms", Method.POST);

            request.AddHeader("Authorization", "Bearer " + bearerToken);

            SendSmsRequest smsRequest = new SendSmsRequest();

            smsRequest.callbackUrl          = null;
            smsRequest.clientDate           = DateTime.Now;
            smsRequest.description          = null;
            smsRequest.isUnsubscribeEnabled = false;
            smsRequest.message              = text;
            smsRequest.phoneNumbers         = new string[1];
            smsRequest.phoneNumbers[0]      = to;
            smsRequest.senderId             = ConfigurationManager.AppSettings["SentlyPlusSenderId"];
            smsRequest.sendWhenMilliseconds = 0;

            request.AddObject(smsRequest);

            var response = client.Execute(request);
        }
        public static void SendMessage(string to, string text)
        {
            lock (lockObj)
            {
                if (bearerToken == null)
                    GetBearerToken();
            }

            var client = new RestClient("https://plus.sent.ly/api/");
            var request = new RestRequest("sms", Method.POST);

            request.AddHeader("Authorization", "Bearer " + bearerToken);

            SendSmsRequest smsRequest = new SendSmsRequest();
            smsRequest.callbackUrl = null;
            smsRequest.clientDate = DateTime.Now;
            smsRequest.description = null;
            smsRequest.isUnsubscribeEnabled = false;
            smsRequest.message = text;
            smsRequest.phoneNumbers = new string[1];
            smsRequest.phoneNumbers[0] = to;
            smsRequest.senderId = ConfigurationManager.AppSettings["SentlyPlusSenderId"];
            smsRequest.sendWhenMilliseconds = 0;

            request.AddObject(smsRequest);

            var response = client.Execute(request);
        }