public void UpdateGeolocation()
        {
            WebmasterToolsService service = new WebmasterToolsService(this.ApplicationName);

            service.Credentials = new GDataCredentials(this.userName, this.passWord);

            try
            {
                SitesQuery q  = new SitesQuery();
                SitesFeed  sf = service.Query(q);

                SitesEntry entry   = new SitesEntry();
                string     siteUrl = "http://www.example.dk/";
                entry.Content.Src  = siteUrl;
                entry.Content.Type = "text/plain";
                SitesEntry newEntry = service.Insert(new Uri(SitesQuery.HttpsFeedUrl), entry);

                newEntry.GeoLocation = "US";
                SitesEntry updatedEntry = newEntry.Update();

                Assert.IsTrue(updatedEntry != null);
                Assert.IsTrue(updatedEntry.GeoLocation == "US");
            }
            finally
            {
                Uri deleteUrl = SitesQuery.CreateCustomUri("http://www.example.dk");
                service.Delete(deleteUrl, null);
            }
        }
        /// <summary>
        /// updates a site entry
        /// </summary>
        /// <param name="entry">the entry to update</param>
        /// <param name="siteId">the id of the site</param>
        /// <returns>the updated site entry</returns>
        public Sites UpdateSiteEntry(Sites entry, string siteId)
        {
            Sites sites = null;

            if (entry != null)
            {
                Uri target = CreateUri(SitesQuery.CreateCustomUri(siteId).AbsoluteUri);

                entry.AtomEntry.EditUri = target;
                SitesEntry se = this.Service.Update(entry.SitesEntry);
                if (se != null)
                {
                    sites           = new Sites();
                    sites.AtomEntry = se;
                }
            }
            return(sites);
        }
Beispiel #3
0
        public void DeleteSite()
        {
            WebmasterToolsService service = new WebmasterToolsService(this.ApplicationName);

            service.Credentials = new GDataCredentials(this.userName, this.passWord);

            SitesQuery feedQuery  = new SitesQuery();
            SitesFeed  beforeFeed = service.Query(feedQuery);

            int before = beforeFeed.Entries.Count;

            Uri deleteUrl = SitesQuery.CreateCustomUri("http://www.example.com");

            service.Delete(deleteUrl);

            SitesFeed afterFeed = service.Query(feedQuery);
            int       after     = afterFeed.Entries.Count;

            Assert.Greater(before, after);
        }
        public void RequestUpdateGeolocation()
        {
            RequestSettings       settings = new RequestSettings("NETUnittests", this.userName, this.passWord);
            WebmasterToolsRequest f        = new WebmasterToolsRequest(settings);

            try
            {
                Sites site    = new Sites("http://www.example.com", "text/plain");
                Sites newSite = f.AddSite(site);

                newSite.GeoLocation = "US";
                //Sites updatedSite = f.Update(newSite);
                Sites updatedSite = f.UpdateSiteEntry(newSite, "http://www.example.com");

                Assert.IsNotNull(updatedSite);
            }
            finally
            {
                Uri deleteUrl = SitesQuery.CreateCustomUri("http://www.example.com");
                f.Delete(deleteUrl, null);
            }
        }