Web Masters API and c# WebClient -
need retrieving site feed given site using google web masters api
webclient client = new webclient(); client.headers.add("authorization: googlelogin auth=" + _auth); client.headers.add("gdata-version: 2"); client.headers.add("content-type", "application/atom+xml"); stream stream = client.openread("https://www.google.com/webmasters/tools/feeds/sites/http%3a%2f%2fando.ueuo.com%2f/"); string str = reader.readtoend();
but every time server return error (400) bad request.
meanwhile same code url https://www.google.com/webmasters/tools/feeds/sites/ work fine , feeds sites expected.
client.headers.add("authorization: googlelogin auth=" + _auth); client.headers.add("gdata-version: 2"); client.headers.add("content-type", "application/atom+xml"); stream stream =client.openread("https://www.google.com/webmasters/tools/feeds/sites/"); streamreader reader = new streamreader(stream); string str = reader.readtoend();
can please?
in "https://www.google.com/webmasters/tools/feeds/sites/http%3a%2f%2fando.ueuo.com%2f/", %2f url encoded equivalent of /. problem have slash right after it, becomes "//".
change "https://www.google.com/webmasters/tools/feeds/sites/http%3a%2f%2fando.ueuo.com%2f"
i find easier use system.web.httputility encoding.
var encodedurl = httputility.urlencode("site name here"); string request = "https://www.google.com/webmasters/tools/feeds/sites/" + encodedurl; stream stream = client.openread(request);
the site name must match shown in webmasters dashboard url site (not named it)
Comments
Post a Comment