Manfred
Hope this helps,
Manfred
To use this in an application, you need to have the username / password
of the user. This API should help:
http://code.google.com/apis/accounts/Authentication.html .
Manfred
Manfred
slishnevsky wrote:
> Update - I can get Google Bookmarks RSS in my application and display
> the data.
> However, All non-english letters are displayed as question marks.
> Something tricky with the encoding.
>
> I have another RSS in the same language (russian) on the same page, it
> shows just fine.
> In both cases RSS encoding is defined as utf-8.
>
> I can't understand why Google Bookmarks RSS shows "??????????" instead
> of russian letters.
>
> I am using ASP.NET 2.0 to display RSS data.
>
> Any advice would be appreciated. Thanks.
You may want to check the response header from Google,
it should read
Content-type text/xml; charset=UTF-8
If _not_ you should check the corresponding request header.
Another way to check it would be the following:
a) manually log-in to your Google account
b) copy the url you provided into your Firefox browser
Can you see the Cyrillic characters ?
Manfred
slishnevsky wrote:
> Thanks Manfred,
> I'll just show my code in C# as it is, it's very simple:
>
> // Need this for authentication
> XmlUrlResolver resolver = new XmlUrlResolver();
> resolver.Credentials = new NetworkCredential("my google username", "my
> google password");
> XmlDocument document = new XmlDocument();
> document.XmlResolver = resolver;
> // Here I load Google Bookmarks RSS, ok
> document.Load("http://www.google.com/bookmarks/lookup?output=rss&sort=title&num=10000");
>
> /*
> Note, at this step debugger already shows me in document.InnerXml
> question marks instead of russian letters. I don't get it. Why? My Web
> config <globalization> section is emty, meaning everything is by
> default in utf-8, RSS itself is in utf-8, next, I just assign that rss
> data to the XmlDataSource component, and so on..., =but it doesn't
> really matter what happens next since I already got "????????" instead
> of letters
> */
>
> XmlDataSource datasource = new XmlDataSource();
> datasource.Data = document.InnerXml;
> datasource.XPath = "rss/channel/item";
> DataList1.DataSource = datasource;
> DataList1.DataBind();
>
> Note, if I don't make any changes in code, and instead of that google
> bookmarks rss I put another rss, like this one for example,
> http://mds.rpod.ru/rss.xml, then everything is just fine.
>
> I am very confused now. Thanks, Any advice would by appreciated.
> In code, when I do this:
> document.Load("http://www.google.com/bookmarks/lookup?output=rss&sort=title&num=10000");
>
> I already get garbage in document.InnerXml.
>
> I though maybe I should check my eyes, I tried to save what I get:
> document.Save("bookmarks.xml").
>
> I check that file, it starts with <?xml version="1.0"
> encoding="utf-8"?>
> The file itself is saved as utf-8 - "Unicode (UTF-8 with signature) -
> Codepage 65001"
>
> Inside - garbage :( How the hell could that be?
Nothing new here - you wrote this same before.
Note. Saving the RSS locally and looking at the local copy does not
proof anything about the actual coding of the file. To be sure you
have to check it with a line trace.
You seem to rely too much on the XML declaration (which is
optional anyway). It's not the only or primary way to determine
the coding.
Manfred
> If so, why would they do that ?
It may be inadvertently triggered by your request. You have seen
already
correct feeds from Google bookmarks showing up in browsers.
> How can I find what is the real encoding of that RSS ?
If you have problems with checking the response headers, just
ask here. You may also trace the line.
If the response headers are correct, I would assume the encoding
is correct also. The next logical step would be to learn more about
the interface you are using and debugging it.
In any case, please don't forget to add here your final conclusions
about
this problem for the benefit of future readers!
Hope this helps, Manfred
Your application is sending a request header to request the feed.
One of the headers sent is
Accept-Charset ISO-8859-1
with _no_ mention of utf-8 I suspect. You can send the web-server
a comma separated list (no blanks), and the web application can
choose from this list. For your purpose both
Accept-Charset utf-8
or
Accept-Charset ISO-8859-1,utf-8
will enable the Google Search-History HTTP Server
to send you the data in the correct UTF-8 encoding.
Note. If you find the Accept-Charset header containig
other parameters, just retain them and separate them
from the charset-list by a semi-colon (";", no blanks).
> I am sure that many RSSs contain error listed in that table. However, I
> don't follow how the browsers display them with no problem. What? They
> all have quite robust RSS analysis and correction engines or something
> like that?
No. But from what I wrote above you certainly got the idea: the
browsers
are sending the correct request-header.
In case you want to read more about the Hypertext Transfer
Protocol -- HTTP/1.1, see
http://www.w3.org/Protocols/rfc2616/rfc2616.html
Hope this helps, Manfred
> HttpWebRequest request =
> (HttpWebRequest)WebRequest.Create("https://www.google.com/bookmarks/lookup?output=rss&sort=title&num=10");
> request.Credentials = new NetworkCredential("username", "password");
> request.Headers[HttpRequestHeader.AcceptCharset] = "utf-8";
In case the _request_ header is still wrong, just a wild guess. Is it
correct
to set the "request.Headers" _after_ the "WebRequest.Create" or should
you
set it before ??
Manfred