Simon Fell > Its just code > May 2002

Sunday, May 19, 2002

Simon wrote: "Here's a suggestion for people writing RSS aggregators, use the HTTP/1.1 Etag and If-None-Match headers so that you only fetch the feed if its changed."

I understand the goal, but not how the implementation would work. Maybe Simon's willing to post some sample header values to shed some light on the idea... [Jake's Radio 'Blog]

Sure, the server response may contain an ETag header, you save this away ascociated with the URL, then on subsequent requests for that url, you include a If-None-Match header with the etag value. If the contents haven't changed, then the server will reply with a 304 Not Modified.

here's an initial request where we don't have a previously obtained etag

GET /weblog/rss.xml HTTP/1.1
Host:
www.pocketsoap.com

And the response

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Mon, 20 May 2002 03:08:54 GMT
Content-Type: text/xml
Accept-Ranges: bytes
Last-Modified: Mon, 20 May 2002 00:20:54 GMT
ETag: "e8d8993494ffc11:b8e"
Content-Length: 9548

<?xml version="1.0"?>
<!-- RSS generated by Radio UserLand v8.0.5 ....

Extract the ETag value, then next time you want that URL, you add the If-None-Match header,

GET /weblog/rss.xml HTTP/1.1
If-None-Match: "e8d8993494ffc11:b8e"
Host:
www.pocketsoap.com

If the file hasn't changed, then it'll still have the same ETag, which matches, so there's no response, just a 304

HTTP/1.1 304 Not Modified
Server: Microsoft-IIS/5.0
Date: Mon, 20 May 2002 03:08:39 GMT
ETag: "e8d8993494ffc11:b8e"
Content-Length: 0

If however the resource has changed, the server assigns it a different Etag, so it no long matches the etag in the request, the server will send the new version

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Mon, 20 May 2002 03:09:54 GMT
Content-Type: text/xml
Accept-Ranges: bytes
Last-Modified: Mon, 20 May 2002 03:09:51 GMT
ETag: "1238993494ffc11:b8f"
Content-Length: 9548

<?xml version="1.0"?>
<!-- RSS generated by Radio UserLand v8.0.5 ....

Wednesday, May 15, 2002

A while back I posted details of how to use PocketSOAP with Word to post new blog entries to Radio.

Here's a new version of that code that now uses PocketXML-RPC this brings a number of advantages

  • Works with other tools besides Radio, the XML-RPC version of the BloggerAPI is implemented by numerous blogging tools.
  • The XML-RPC version of the BloggerAPI can be enabled from the prefs page in Radio, no need to run the script that enables the SOAP version.

In additon it also handles paragraphs better, based on a suggestion from Omar Shahine [who by the way did a Mac port of the SOAP version]

First off, make sure you've got PocketXML-RPC installed, and for the Radio folks goto the prefs page and make sure that XML-RPC & SOAP are enabled, and that the Blogger API is enabled. Now you can make XML-RPC calls to manage your blog.

The code is just a few simple Word macros that use PocketXML-RPC to make the XML-RPC calls to the BloggerAPI. Download this VBA module. Now fire up Word and select Tools -> Macro -> Visual Basic Editor. Now import the module into your document, or if you want the macro's always available, import them into your template (expand the tree Normal -> Microsoft Word Objects and right click and select Import File).

Look at the top of the code, there are some settings you'll need to tweak. First you'll need to enter your username & password, these are configured in the Remote Access & Security prefs page. If you want to use Word on a different machine to the machine running Radio, you'll need to tweak the RADIO_URL setting. Finally if you need to connect via a HTTP proxy, you can alter the PROXY_SERVER and PROXY_PORT settings.

Now switch back to the main word document window, enter your post and hit Tools -> Macro -> Macros -> select PostNewBlogEntry and hit run. This will send the document as a new post to Radio. Now change the entry and run the UpdateBlogEntry macro, this will prompt you for a postID which will default to the just created post. This will now post the revised text as an edit to the original post. Hey presto you're blogging from Word!

The post takes some simple HTML formatting from the document, link, italics & bold are all carried over.

You can use the Tools -> Customize options to assign the macro's to buttons on the toolbar and/or keyboard shortcuts.