Esempio n. 1
0
        /// <summary>
        /// This method contains the actual sample code.
        /// </summary>
        private static void RunVerification(SiteVerificationService service)
        {
            // Request user input.
            string site = Util.GetSingleLineClipboardContent(96);

            CommandLine.WriteAction("Please enter the URL of the site to verify:");
            CommandLine.RequestUserInput("URL", ref site);
            CommandLine.WriteLine();

            // Example of a GetToken call.
            CommandLine.WriteAction("Retrieving a meta token ...");
            var request = service.WebResource.GetToken(new SiteVerificationWebResourceGettokenRequest()
            {
                VerificationMethod = "meta",
                Site = new SiteVerificationWebResourceGettokenRequest.SiteData()
                {
                    Identifier = site,
                    Type       = "site"
                }
            });
            var response = request.Fetch();

            CommandLine.WriteResult("Token", response.Token);
            Util.SetClipboard(response.Token);
            CommandLine.WriteLine();

            CommandLine.WriteAction("Please place this token on your webpage now.");
            CommandLine.PressEnterToContinue();
            CommandLine.WriteLine();

            // Example of an Insert call.
            CommandLine.WriteAction("Verifiying...");
            var body = new SiteVerificationWebResourceResource();

            body.Site            = new SiteVerificationWebResourceResource.SiteData();
            body.Site.Identifier = site;
            body.Site.Type       = "site";
            var verificationResponse = service.WebResource.Insert(body, "meta").Fetch();

            CommandLine.WriteResult("Verification", verificationResponse.Id);
            CommandLine.WriteAction("Verification successful!");
        }
        /// <summary>
        /// This method contains the actual sample code.
        /// </summary>
        private static void RunVerification(SiteVerificationService service)
        {
            // Request user input.
            Console.WriteLine("Please enter the URL of the site to verify:");
            var site = Console.ReadLine();

            Console.WriteLine();

            // Example of a GetToken call.
            Console.WriteLine("Retrieving a meta token ...");
            var request = service.WebResource.GetToken(new SiteVerificationWebResourceGettokenRequest()
            {
                VerificationMethod = "meta",
                Site = new SiteVerificationWebResourceGettokenRequest.SiteData()
                {
                    Identifier = site,
                    Type       = "site"
                }
            });
            var response = request.Execute();

            Console.WriteLine("Token: " + response.Token);
            Console.WriteLine();

            Console.WriteLine("Please place this token on your webpage now.");
            Console.WriteLine("Press ENTER to continue");
            Console.ReadLine();
            Console.WriteLine();

            // Example of an Insert call.
            Console.WriteLine("Verifying...");
            var body = new SiteVerificationWebResourceResource();

            body.Site            = new SiteVerificationWebResourceResource.SiteData();
            body.Site.Identifier = site;
            body.Site.Type       = "site";
            var verificationResponse = service.WebResource.Insert(body, "meta").Execute();

            Console.WriteLine("Verification:" + verificationResponse.Id);
            Console.WriteLine("Verification successful!");
        }
        /// <summary>
        /// Modify the list of owners for your website or domain.
        /// Documentation https://developers.google.com/siteverification/v1/reference/webResource/update
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated siteVerification service.</param>
        /// <param name="id">The id of a verified site or domain.</param>
        /// <param name="body">A valid siteVerification v1 body.</param>
        /// <returns>SiteVerificationWebResourceResourceResponse</returns>
        public static SiteVerificationWebResourceResource Update(siteVerificationService service, string id, SiteVerificationWebResourceResource body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (id == null)
                {
                    throw new ArgumentNullException(id);
                }

                // Make the request.
                return(service.WebResource.Update(body, id).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request WebResource.Update failed.", ex);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Attempt verification of a website or domain.
        /// Documentation https://developers.google.com/siteverification/v1/reference/webResource/insert
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Siteverification service.</param>
        /// <param name="verificationMethod">The method to use for verifying a site or domain.</param>
        /// <param name="body">A valid Siteverification v1 body.</param>
        /// <returns>SiteVerificationWebResourceResourceResponse</returns>
        public static SiteVerificationWebResourceResource Insert(SiteverificationService service, string verificationMethod, SiteVerificationWebResourceResource body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (verificationMethod == null)
                {
                    throw new ArgumentNullException(verificationMethod);
                }

                // Make the request.
                return(service.WebResource.Insert(body, verificationMethod).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request WebResource.Insert failed.", ex);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// This method contains the actual sample code.
        /// </summary>
        private static void RunVerification(SiteVerificationService service)
        {
            // Request user input.
            string site = Util.GetSingleLineClipboardContent(96);
            CommandLine.WriteAction("Please enter the URL of the site to verify:");
            CommandLine.RequestUserInput("URL", ref site);
            CommandLine.WriteLine();
            
            // Example of a GetToken call.
            CommandLine.WriteAction("Retrieving a meta token ...");
            var request = service.WebResource.GetToken(new SiteVerificationWebResourceGettokenRequest()
            {
                VerificationMethod = "meta",
                Site = new SiteVerificationWebResourceGettokenRequest.SiteData()
                {
                    Identifier = site,
                    Type = "site"
                }
            });
            var response = request.Fetch();
            CommandLine.WriteResult("Token", response.Token);
            Util.SetClipboard(response.Token);
            CommandLine.WriteLine();

            CommandLine.WriteAction("Please place this token on your webpage now.");
            CommandLine.PressEnterToContinue();
            CommandLine.WriteLine();

            // Example of an Insert call.
            CommandLine.WriteAction("Verifiying...");
            var body = new SiteVerificationWebResourceResource();
            body.Site = new SiteVerificationWebResourceResource.SiteData();
            body.Site.Identifier = site;
            body.Site.Type = "site";
            var verificationResponse = service.WebResource.Insert(body, "meta").Fetch();
            CommandLine.WriteResult("Verification", verificationResponse.Id);
            CommandLine.WriteAction("Verification successful!");
        }
        /// <summary>
        /// This method contains the actual sample code.
        /// </summary>
        private static void RunVerification(SiteVerificationService service)
        {
            // Request user input.
            Console.WriteLine("Please enter the URL of the site to verify:");
            var site = Console.ReadLine();
            Console.WriteLine();

            // Example of a GetToken call.
            Console.WriteLine("Retrieving a meta token ...");
            var request = service.WebResource.GetToken(new SiteVerificationWebResourceGettokenRequest()
            {
                VerificationMethod = "meta",
                Site = new SiteVerificationWebResourceGettokenRequest.SiteData()
                {
                    Identifier = site,
                    Type = "site"
                }
            });
            var response = request.Execute();
            Console.WriteLine("Token: " + response.Token);
            Console.WriteLine();

            Console.WriteLine("Please place this token on your webpage now.");
            Console.WriteLine("Press ENTER to continue");
            Console.ReadLine();
            Console.WriteLine();

            // Example of an Insert call.
            Console.WriteLine("Verifying...");
            var body = new SiteVerificationWebResourceResource();
            body.Site = new SiteVerificationWebResourceResource.SiteData();
            body.Site.Identifier = site;
            body.Site.Type = "site";
            var verificationResponse = service.WebResource.Insert(body, "meta").Execute();

            Console.WriteLine("Verification:" + verificationResponse.Id);
            Console.WriteLine("Verification successful!");
        }