Ejemplo n.º 1
0
        public async Task SendSmsQuery()
        {
            var formContent = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("isTest", "false"),
                new KeyValuePair <string, string>("goformId", "SEND_SMS"),
                new KeyValuePair <string, string>("notCallback", "true"),
                new KeyValuePair <string, string>("Number", "+79117495435"),
                new KeyValuePair <string, string>("sms_time", DecodeMessage.GetCurrentTimeString()),
                new KeyValuePair <string, string>("MessageBody", DecodeMessage.EncodeMessage("Privet,!.134577 Егор")),
                new KeyValuePair <string, string>("ID", "-1"),
                new KeyValuePair <string, string>("encode_type", "UNICODE")
            });

            using (var myHttpClient = new HttpClient())
            {
                UnsafeHeaderParsing.SetAllowUnsafeHeaderParsing(true);
                var response = await myHttpClient.PostAsync("http://192.168.0.1" + Constants.Constants.POSTURLPREFIX, formContent);

                if (response.IsSuccessStatusCode)
                {
                    UnsafeHeaderParsing.SetAllowUnsafeHeaderParsing(false);
                }
                UnsafeHeaderParsing.SetAllowUnsafeHeaderParsing(false);
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> SendSms(Message message)
        {
            var formContent = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("isTest", "false"),
                new KeyValuePair <string, string>("goformId", "SEND_SMS"),
                new KeyValuePair <string, string>("notCallback", "true"),
                new KeyValuePair <string, string>("Number", message.Number),
                new KeyValuePair <string, string>("sms_time", DecodeMessage.GetCurrentTimeString()),
                new KeyValuePair <string, string>("MessageBody", DecodeMessage.EncodeMessage(message.Text)),
                new KeyValuePair <string, string>("ID", "-1"),
                new KeyValuePair <string, string>("encode_type", "UNICODE")
            });

            using (var myHttpClient = new HttpClient())
            {
                UnsafeHeaderParsing.SetAllowUnsafeHeaderParsing(true);
                var response = await myHttpClient.PostAsync(Constants.Constants.BASEMODEMURL + Constants.Constants.POSTURLPREFIX, formContent);

                if (response.IsSuccessStatusCode)
                {
                    UnsafeHeaderParsing.SetAllowUnsafeHeaderParsing(false);
                    return(true);
                }
                UnsafeHeaderParsing.SetAllowUnsafeHeaderParsing(false);
                return(false);
            }
        }