Simon Fell > Its just code > Subscriber Interface for weblogs.com

Tuesday, February 12, 2002

As a fully fledged weblogs.com adict, i find the hourly update in Radio to be too long a wait, so i constantly have www.weblogs.com open, and keep hitting refresh, looking for blogs that i follow.

So, to help build a better tool for this, i started by building a subscriber interface to the weblogs.com data. You register the URL(s) of the weblogs you want to subscribe to, and the port & path of where your callback handler is [it must be at the same address as the subscribe call]. Then when the service sees a change in any of the URL's you subscribed to, it'll call you back with a SOAP message saying its updated.

This is just the ground work, more interesting scenarios can be built on top of this. Radio would be an obvious client, as it already has something to manage a list of favorites, just need some code to subscribe to all your favourites, and a callback listener that tracks the callsbacks, and displays them somewhere obvious.

There's also scope for a small stand alone app that does something similar.

In addition other notification layers can be built on top, such as IM messages, .NET Alerts, email, SMS etc.

The WSDL that describes the subscription interface is here. Here's a sample subscribe request generated by PocketSOAP

POST http://soap.4s4c.com/weblogs/subscribe.asmx HTTP/1.0
Content-Type: text/xml; charset=UTF-8
User-Agent: pocketSOAP/1.3.beta.2
Accept-Charset: UTF-8, UTF-16
Host: soap.4s4c.com
Content-Length: 701
SOAPAction: "
http://soap.pocketsoap.com/weblogs.com/Subscribe"

<S:Envelope
 S:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
 xmlns:Enc='http://schemas.xmlsoap.org/soap/encoding/'
 xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'
 xmlns:a='http://soap.pocketsoap.com/weblogs.com/'
 xmlns:XS='http://www.w3.org/2001/XMLSchema'
 xmlns:XI='http://www.w3.org/2001/XMLSchema-instance'>
<S:Body><a:Subscribe><urls XI:type='Enc:Array' Enc:arrayType='XS:anyType[2]'><i XI:type='XS:string'>http://www.pocketsoap.com/weblog/</i>
<i XI:type='XS:string'>http://www.razorsoft.net/weblog/</i>
</urls>
<callback_port XI:type='XS:int'>80</callback_port>
<callback_path XI:type='XS:string'>/dummy.asp</callback_path>
</a:Subscribe>
</S:Body></S:Envelope>

When the service sees a change in a weblog you are subscribed to, it'll call you back with a message like

<sp:Envelope
  sp:EncodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:sp="http://schemas.xmlsoap.org/soap/envelope/">
  <sp:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/">
    <m:updated xmlns:m="http://soap.pocketsoap.com/weblogs.com/">
      <weblogs enc:arrayType="m:weblog[1]"
          xsi:type="enc:Array">
        <weblog xsi:type="m:weblog">
          <url xsi:type="xsd:anyURI">http://www.pocketsoap.com/weblog/</url>
          <name xsi:type="xsd:string">its just code</name>
          <timestamp xsi:type="xsd:dateTime">2002-02-15T07:29:26Z</timestamp>
        </weblog>
      </weblogs>
    </m:updated>
  </sp:Body>
</sp:Envelope>

Subscriptions are valid for 48 hours, you need to call subscribe again before the 48 hours expires to renew the subscription.

Changes are polled from weblogs.com, so there can be upto a 5 minute delay before you'll get a notification callback