Bloggitation

Enlightment via blog-kata

WebHooks on AppJet

leave a comment »

Hi everybody,
I created a small lib-webhook library and a small companion hooks application for easy working with webhooks on AppJet. Like maybe you know, webhooks are one of the current hot topics. They are a very easy way to implement a real-time communications between remote applications.

What you can use it for:

  1. Notify your AppJet based application about changes (commits etc.) in your GitHub repository – have for example ChangeLog + user notifications to some ML:

    Just go to GitHub Admin|Hooks page and if the already defined hooks are not enough put http://youhooks.appjet.net/github/SomeSecret/ there.

  2. Post to your AppJet based application by Jabber (XMPP) or from an iPhone:

    go to https://ping.fm/custom/ and enter http://youhooks.appjet/pingfm/SomeSecret/ . ping.fm have a XMPP bot and an iPhone application which you can use.

  3. Post to your AppJet application by email:

    http://www.smtp2web.com/ , define some email address and point the URL to http://youhooks.appjet.net/something/SomeSecret/. In fact I’m first pointing it to one small application on GAE itself, because parsing multipart/rfc-822 coded message parameter will be difficult on AppJet. So I’m parsing it with message.get_payload() and repacking it in JSON payload. After this it can be send to AppJet.

  4. Posting to XMPP from AppJet – it still missing on AppJet, so I have a small Heroku-hosted Sinatra application to implement this feature. So http://youhooks.appjet.net/xmpp/SomeSecret/ will in turn call that Sinatra application. If you do not trust me with your XMPP information, just create your own application somewhere, where XMPP is possible and call it with a webhooks API (your_url, JSON(payload),JSON(data)).

How to use lib-webhook and hooks application:

  1. Clone the hooks application to (for example) http://youhooks.appjet.net/
  2. Set your secret token – it will be added to the end of the URLs:
      // from the shell
      import ("storage", "lib-webhook");
      storage.token = "SomeSecret";
    
  3. Define users for the hooks, that needed them. I need for example user/password for the XMPP hook and user/key for the http://bit.ly/ URL shortening service. In this way they will be not visible in your application sources.
    // from the shell
    HOOK.addUser("xmpp", {user:"...", password:"..."});
    

    In the moment my hooks application just inserting the user’s data with the same name as the hook, if such user exists:

    data = HOOK.addUserData(data, hook);
    

The library itself provide two main functions:

// universal caller - remote or local hooks:
string callH(url, JSON(payload), JSON(data));
// call local hooks by name
string callLocalH(name, payload, data);

The rest are just some small helpers for user’s data management.

I’ll be very happy to see clones of hooks application with some interesting webhooks (http://pbwiki.com/ for example also supporting webhooks. and by the way PayPal also wink ). And about lib-webhook – will add twitter, identi.ca and maybe some others local hooks ASAP.

Let’s the source be with you.

Advertisements

Written by zhesto

23-Feb-2009 at 12:03 UTC

Leave a Reply

Please log in using one of these methods to post your comment:

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: