This morning I came across a tip Jonas Galvez posted a few months ago entitled Proxy your Gmail feed with Python.
I thought (as you do) “That looks like fun” and decided to knock out a C# version.
So here it is, wrapped up in a nice cuddly method but without any error checking, asynchronous processing or other fanciness (it was just an idle fiddle after all...I'll look at doing something with it later):
private
static XmlDocument GetGmailFeed(string userName, string password)
{
HttpWebRequest req =
(HttpWebRequest)WebRequest.Create(https://gmail.google.com/gmail/feed/atom);
req.Method = "GET";
req.Credentials = new NetworkCredential(userName,password);
XmlDocument response = new XmlDocument();
HttpWebResponse resp;
resp = (HttpWebResponse)req.GetResponse();
if(resp.StatusCode==HttpStatusCode.OK)
{
XmlTextReader reader = new XmlTextReader(resp.GetResponseStream());
response.Load(reader);
reader.Close();
}
resp.Close();
return response;
}
Of course, Most aggregators will happily consume the feed for you if you can provide them with your credentials, but where's the fun in that?