Getting webhook callbacks when people click-through links

August 13, 2009

So I recently put this blog’s feed through FeedBurner. If I recall, I think I wanted to get subscriber statistics, as well as to try out their integration of PubSubHubbub publishing. But since I didn’t think I would get new subscribers often and I’m too lazy to check stats, I really wanted a way to be notified when people subscribed. Since the means of subscribing would be a link, it hit me: click-through webhooks.

I wanted a link wrapper that would trigger a URL callback (aka a webhook) when people clicked through the link. Similar to a URL shortener, you’d just give it a URL and it would give you another URL, but instead of being shorter, it would be tied to a callback that would run as it redirected the user to the original URL. What could you do with this, you ask? It’s a webhook; you can do anything with this event.

Coming back to my original use case, I’d probably tie it to a script that sent me an IM that somebody subscribed. Or better yet, with something like Yapper, I could get a Growl notification. Sweet, right?

I knew it would be trivial to build, and even though it was a feature that I really wanted, it was still just a feature. I thought, it really doesn’t need its own app, does it? So I went to my URL shortener of choice, tr.im, and suggested it as a feature. I also happened to mention to all my friends they should vote it up. Well, it ended up being the 6th most requested feature because of that. I thought for sure they’d implement it. I mean it was so much easier than the others, and I gave them code to help do it and everything.

A couple weeks went by and nothing happened. I got no response. I emailed them and got nothing back. They didn’t even mark it as “under review.” It may have had to do with the fact they were then deciding to shut down … which I hear they’ve changed their mind about. Nevertheless, it still hadn’t happened. And I really wanted to be able to do this notification on subscription thing!

Along came my WebHooks and PubSubHubbub meetup where I wanted to demo this bit of plumbing. Of course, I had no way to do it because nobody had implemented it. So I figured I’d just build it that day before the meetup. Twenty minutes later, I had it live: ClickHooks.

Okay, so that part’s done. How do I get it to IM me? Well, Scriptlets was made to write the glue code to use with these kinds of webhooks. And my project Protocol Droid was made to make it easy to use other protocols from HTTP. So I just threw this little baby on Scriptlets and I was done:

import urllib

payload = {
 'username': 'demo@progrium.com',
 'password': 'secret',
 'to': 'progrium@gmail.com',
 'body': "You got a new subscriber on blogrium!"
}

fetch("http://pdroid.progrium.com/xmpp:talk.google.com/send", urllib.urlencode(payload), "POST")

Yes, that pdroid endpoint is live. No, I don’t recommend using it for production. Stand up your own Protocol Droid gateway. ;)

Anyway, simple enough to understand though, right? It should be. And it was simple to get set up. That’s the whole point of a world of webhooks: you can easily do so much cool stuff if this simple infrastructure is there.

As an aside, later I realized I could generalize my IM scriptlet to use a GET param for the body of the message, allowing me to make a personal messaging micro-webservice: http://www.scriptlets.org/abcdef?body=Hello, world! The data in this URL could then be hidden behind a URL shortener, giving me a regular looking URL that I could then give to people that would IM me the message when they clicked it. Kind of silly, but I almost set up a link that would IM me “At the door!” that people could click from their phone browsers as a doorbell for the WebHooks meetup.

Ah, fun with infrastructure.

10 Responses to “Getting webhook callbacks when people click-through links”

  1. Drew LeSueur Says:

    It’s cool to see how you are using your own tools together.

    Imagine a doorbell that actually made an HTTP post.

    • Jeff Lindsay Says:

      Drew, yeah! Actually during the webhooks meetup I was playing with the remote control for the projector and said, “Remember programmable remotes? They’ll be back … with webhooks.”

  2. Julien Says:

    It would be even cooler if, say, for example, we could plug that to Google analytics to get a lot of small data (referer, etc… of who clicked on the link…) Doable?

    • Jeff Lindsay Says:

      I thought about that. You could make a service that redirects in the client and the page that you have in between has Google Analytics. Since webhooks are server-side, it’s harder to collect a lot of that stuff.

      • DachaiCh Says:

        I like the way you both are thinking here. Question. With the way Google has revamped their analytical tool, would webhooks increase the amount of times their server acknowledges a post? Activity wise that is.


  3. […] Getting webhook callbacks when people click-through links « blogrium.   […]


  4. This particular article, “Getting webhook callbacks when people click-through links | blogrium” was in fact outstanding.
    I am creating out a reproduce to show my buddies.
    Many thanks,Les


  5. Asking questions are genuinely pleasant thing if you are not understanding anything totally, however
    this piece of writing gives nice understanding yet.

  6. tinyurl.com Says:

    I actually intend to bookmark this posting, “Getting webhook callbacks when people click-through
    links | blogrium” z-ita on my very own page.
    Do you really care in the event Ido it? Thanks -Dawn


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: