Ejemplo n.º 1
0
        private async Task <string> SendRequest(string api_bot_method_name, NameValueCollection request_param)
        {
            http_response_raw = "";
            if (request_param != null && !string.IsNullOrEmpty(request_param["text"]) && string.IsNullOrWhiteSpace(request_param["parse_mode"]))
            {
                request_param["text"] = HttpUtility.UrlEncode(request_param["text"]);
            }

            await Task.Run(() =>
            {
                http_response_raw = MyWebClient.SendRequest(apiUrl + "/" + api_bot_method_name, HttpMethod.Post, request_param, null, MyWebClient.RequestContentTypes.ApplicationXWwwFormUrlencoded);
            });

            return(http_response_raw);
        }
Ejemplo n.º 2
0
        private async Task <string> SendRequest(string api_bot_method_name, NameValueCollection request_param, InputFileClass file_post)
        {
            http_response_raw = "";
            if (request_param != null && !string.IsNullOrEmpty(request_param["captiom"]) && string.IsNullOrWhiteSpace(request_param["parse_mode"]))
            {
                request_param["captiom"] = HttpUtility.UrlEncode(request_param["captiom"]);
            }

            await Task.Run(() =>
            {
                http_response_raw = MyWebClient.SendRequest(apiUrl + "/" + api_bot_method_name, HttpMethod.Post, request_param, new List <PostedFile>()
                {
                    new PostedFile()
                    {
                        Data = file_post.Data, FieldName = file_post.FieldName, FileName = file_post.FileName
                    }
                }, MyWebClient.RequestContentTypes.MultipartFormData);
            });

            return(http_response_raw);
        }