示例#1
0
        private async Task PerformPrivacyConsentRequestAsync()
        {
            if (CheckIfLoggedInAsync())
            {
                return;
            }

            await UpdateTumblrKey();

            const string referer = @"https://www.tumblr.com/privacy/consent?redirect=";
            var          headers = new Dictionary <string, string> {
                { "X-tumblr-form-key", tumblrKey }
            };
            HttpWebRequest request =
                webRequestFactory.CreatePostXhrReqeust("https://www.tumblr.com/svc/privacy/consent", referer, headers);
            const string requestBody = "{\"eu_resident\":true,\"gdpr_is_acceptable_age\":true,\"gdpr_consent_core\":true,\"gdpr_consent_first_party_ads\":true,\"gdpr_consent_third_party_ads\":true,\"gdpr_consent_search_history\":true,\"redirect_to\":\"\"}";

            request.ContentType = "application/json";
            await webRequestFactory.PerformPostXHRReqeustAsync(request, requestBody);

            using (var response = await request.GetResponseAsync() as HttpWebResponse)
            {
                cookieService.SetUriCookie(response.Cookies);
            }
        }