Beispiel #1
0
        /// <summary>
        /// Status profile
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task StatusSet(string userId)
        {
            string url = StatusProfileApi + userId;

            StringBuilder postData = new StringBuilder();

            postData.Append("usersIds[]=" + WebUtility.UrlEncode(userId));
            await PostRequestFormData(url + ConvertToAjaxTime.ConvertToUnixTimestamp().ToString(),
                                      "profile.onliner.by",
                                      "https://profile.onliner.by",
                                      postData.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// POST request to add a comment
        /// </summary>
        public async Task <bool> AddComments(string newsID, string message, string linkNews)
        {
            if (newsID == string.Empty)
            {
                throw new Exception();
            }
            if (message == string.Empty)
            {
                throw new Exception();
            }

            if (!HasInternet())
            {
                throw new WebException();
            }

            HttpClient         httpClient  = new HttpClient(HandlerCookie());
            var                finalURl    = GetApionLinks(linkNews) + ConvertToAjaxTime.ConvertToUnixTimestamp().ToString();
            HttpRequestMessage postRequest = new HttpRequestMessage(HttpMethod.Post, finalURl);

            postRequest.Headers.Add("Accept", "application/json, text/javascript, */*; q=0.01");
            postRequest.Headers.Add("Accept-Encoding", "gzip, deflate");
            postRequest.Headers.Add("Accept-Language", "en-US,en;q=0.8,ru;q=0.6");
            postRequest.Headers.Add("Referer", $"{linkNews}");
            postRequest.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36");
            postRequest.Headers.Add("X-Requested-With", "XMLHttpRequest");
            StringBuilder postData = new StringBuilder();

            postData.Append("message=" + WebUtility.UrlEncode(message) + "&");
            postData.Append("postId=" + WebUtility.UrlEncode(newsID));
            postRequest.Content = new System.Net.Http.StringContent(postData.ToString(), UnicodeEncoding.UTF8, "application/x-www-form-urlencoded");
            response            = await httpClient.SendAsync(postRequest);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        public async Task <string> NewsViewAll(string url, string newsIDList)
        {
            string quoteUrl = url + "viewcounter/count/?" + newsIDList + "token=" + ConvertToAjaxTime.ConvertToUnixTimestamp().ToString();

            if (!HasInternet())
            {
                throw new WebException();
            }
            HttpClientHandler handler = new HttpClientHandler();

            if (CookieSession != null)
            {
                handler.CookieContainer = CookieSession;
            }
            HttpClient         httpClient  = new HttpClient(handler);
            HttpRequestMessage postRequest = new HttpRequestMessage(HttpMethod.Get, quoteUrl);

            postRequest.Headers.Add("Accept", "application/json, text/javascript, */*; q=0.01");
            postRequest.Headers.Add("X-Requested-With", "XMLHttpRequest");
            var response   = httpClient.SendAsync(postRequest).Result;
            var resultJson = await response.Content.ReadAsStringAsync();

            return(resultJson);
        }
Beispiel #4
0
        public async Task <string> QuoteComment(string commentId, string url)
        {
            string quoteUrl = QuoteMessageUrlGenerate(url) + commentId + "?" + ConvertToAjaxTime.ConvertToUnixTimestamp().ToString();

            if (!HasInternet())
            {
                throw new WebException();
            }
            HttpClientHandler handler = new HttpClientHandler();

            if (CookieSession != null)
            {
                handler.CookieContainer = CookieSession;
            }
            HttpClient         httpClient  = new HttpClient(handler);
            HttpRequestMessage postRequest = new HttpRequestMessage(HttpMethod.Get, quoteUrl);

            postRequest.Headers.Add("Accept", "application/json, text/javascript, */*; q=0.01");
            postRequest.Headers.Add("X-Requested-With", "XMLHttpRequest");
            var response   = httpClient.SendAsync(postRequest).Result;
            var resultJson = await response.Content.ReadAsStringAsync();

            return(Regex.Unescape(resultJson));
        }
Beispiel #5
0
        /// <summary>
        /// GET request for a list of messages
        /// <param name="f">type message: inbox = 0, outbox = -1, saveimage = 1</param>
        /// <param name="p">1</param>
        /// </summary>
        public async Task <MessageJson> Message(string f, string p)
        {
            MessageJson message = null;
            string      url     = $"https://profile.onliner.by/messages/load/?f={f}&p={p}&token=" + ConvertToAjaxTime.ConvertToUnixTimestamp().ToString();

            try
            {
                if (!HasInternet())
                {
                    return(message);
                }
                HttpClient httpClient = new HttpClient(HandlerCookie());
                var        response   = httpClient.SendAsync(new HttpRequestMessage(System.Net.Http.HttpMethod.Get, url)).Result;
                var        resultJson = await response.Content.ReadAsStringAsync();

                var regex    = new Regex("(\"m\\d+\":)", RegexOptions.Compiled | RegexOptions.Multiline);
                var myString = regex.Replace(resultJson, "").Replace("\"messages\":{", "\"messages\":[").Replace("}}}", "}]}");
                message = (MessageJson)JsonConvert.DeserializeObject <MessageJson>(myString);
            }
            catch (WebException) { }
            return(message);
        }