google oauth - Submit Site Map Using C# -


i using follwoign code submit site map webmaster tools

google.gdata.webmastertools.webmastertoolsservice service =      new google.gdata.webmastertools.webmastertoolsservice("www.test1.com"); service.setusercredentials("email", "password"); string lwebsite = "http%3a%2f%2fwww%2etest1%2ecom%2f"; query.uri = new uri("https://www.google.com/webmasters/tools/feeds/sites/");  google.gdata.webmastertools.sitemapsentry se =      new google.gdata.webmastertools.sitemapsentry(); se.content.src = "http://www.test1.com/sitemap.xml"; se.content.type = "text/xml"; google.gdata.webmastertools.sitemapsentry ret =      service.insert(         new uri("https://www.google.com/webmasters/tools/feeds/sites/" + lwebsite + "/sitemaps/"), se); 

but no luck code. can 1 provide me sample code submit site map?

code ripped google-webmastertools sample

pm> install-package google.apis.webmasters.v3

authenticate using oauth2:

/// <summary>         /// authenticate google using oauth2         /// documentation https://developers.google.com/accounts/docs/oauth2         /// </summary>         /// <param name="clientid">from google developer console https://console.developers.google.com</param>         /// <param name="clientsecret">from google developer console https://console.developers.google.com</param>         /// <param name="username">a string used identify user.</param>         /// <returns></returns>         public static webmastersservice  authenticateoauth(string clientid, string clientsecret, string username)         {              string[] scopes = new string[] { webmastersservice.scope.webmastersreadonly};     // view analytics data              try             {                 // here request user give access, or use refresh token stored in %appdata%                 usercredential credential = googlewebauthorizationbroker.authorizeasync(new clientsecrets { clientid = clientid, clientsecret = clientsecret }                                                                                              , scopes                                                                                              , username                                                                                              , cancellationtoken.none                                                                                              , new filedatastore("daimto.googlewebmasters.auth.store")).result;                  webmastersservice service = new webmastersservice(new baseclientservice.initializer()                 {                     httpclientinitializer = credential,                     applicationname = "webmasters api sample",                 });                 return service;             }             catch (exception ex)             {                  console.writeline(ex.innerexception);                 return null;              }          } 

call authentication method

string client_id = "xxx-d0vpdthl4ms0soutcrpe036ckqn7rfpn.apps.googleusercontent.com";             string client_secret = "ndmlunftguk6wgmy7cfo64rv";             var service = authenticateoauth(client_id, client_secret, "test"); 

fetch data

   var x =  service.urlcrawlerrorscounts.query(site).execute(); 

the sample project has helper methods site map


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -