Ejemplo n.º 1
0
        public async Task GetRecomendationCore()
        {
            List <string> tokenCollection = accountInformation.GetTokenFromFile();

            for (int i = 0; i < tokenCollection.Count; i++)
            {
                string         urls    = "https://api.gotinder.com/v2/recs/core?locale=ru";
                HttpWebRequest request = WebRequest.Create(urls) as HttpWebRequest;
                request.Method      = "GET";
                request.UserAgent   = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36";
                request.ContentType = "application/json";
                request.Headers.Add("X-Auth-Token", tokenCollection[i]);
                //   requestSecond.Headers.Add("X-Supported-Image-Formats", "webp,jpeg");
                HttpWebResponse response = null;
                try
                {
                    response = await request.GetResponseAsync() as HttpWebResponse;

                    string content = string.Empty;
                    using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                    {
                        content = await reader.ReadToEndAsync();

                        reader.Close();
                    }
                    response.Close();
                    response.Dispose();
                    RootObject = JsonConvert.DeserializeObject <RootObject>(content);
                }

                catch (WebException ex)
                {
                    string message = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
                    MessageBox.Show("Превышен лимит", message);
                }
                finally
                {
                    response.Close();
                    response.Dispose();
                }
            }
        }