Thursday, December 02, 2004

Atom.NET

I found a great open-source library for interacting with Atom-capable blog sites like Blogger. This is MUCH more effective than the half-baked WSDL posted on the AtomEnabled site. There are also some helpful examples on the project site. Here's the VB.NET example of connecting to a blog through a proxy server translated to C#:

HttpWebRequest blogWebRequest = (HttpWebRequest)HttpWebRequest.Create("http://yourbloghere.blogspot.com/atom.xml");
WebProxy proxy = new WebProxy("proxy.someaddress.com", 8080);
blogWebRequest.Proxy = proxy;

try
{
   StreamReader responseStream = new StreamReader(
         blogWebRequest.GetResponse().GetResponseStream(),
         System.Text.Encoding.ASCII);

   myBlogFeed = Atom.Core.AtomFeed.Load(responseStream);
}
catch (System.Net.WebException webExc)
{
   MessageBox.Show(webExc.Message, "Web Exception");
}

I also played with the WebProxy.GetDefaultProxy() method to grab settings from IE, but wasn't able to get it working. I'm thinking it may be because the GetDefaultProxy() method will only get "nondynamic proxy settings" and at work we use a configuration script to set proxy. Oh, well. I'm going to continue tinkering with this library and see if I can actually post a new entry to my blog.

- Tony

No comments:

Post a Comment