コード例 #1
0
        public void Post(string messageContent, List <ContactModel> contacts)
        {
            RestClient client = new RestClient();

            NameValueCollection clients = new NameValueCollection();

            foreach (var item in contacts)
            {
                clients.Add(item.ContactPhone, "clients");
            }


            string message_body = messageContent;


            ModelToSendToRemoteServer modelToSendToRemoteServer = new ModelToSendToRemoteServer(message_body, clients);

            var obj = new JavaScriptSerializer();

            string jsonResult = obj.Serialize(modelToSendToRemoteServer);

            Console.WriteLine(jsonResult);

            RestRequest request = new RestRequest("http://127.0.0.1:5000//api/send/scheduledMessage", DataFormat.Json);

            request.AddJsonBody(jsonResult);

            IRestResponse response = client.Post(request);
        }
コード例 #2
0
        public IRestResponse sendSimpleMessage(SimpleMessageModel simpleMessageModel)
        {
            RestClient client = new RestClient();

            NameValueCollection clients = new NameValueCollection();

            foreach (var item in simpleMessageModel.Clients)
            {
                clients.Add(item, "clients");
            }

            string message_body = simpleMessageModel.MessageBody;

            ModelToSendToRemoteServer modelToSendToRemoteServer = new ModelToSendToRemoteServer(message_body, clients);

            var obj = new JavaScriptSerializer();

            string jsonResult = obj.Serialize(modelToSendToRemoteServer);

            Console.WriteLine(jsonResult);

            RestRequest request = new RestRequest("http://127.0.0.1:5000/api/send/scheduledMessage", DataFormat.Json);

            request.AddJsonBody(jsonResult);

            IRestResponse response = client.Post(request);

            return(response);
        }