This is a quick introduction to webhooks I gave at GlueCon 2010. It was also a bit of an ad for a last minute 40 minute talk I was giving immediately after.
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
WebHooks in 10 Minutes
1. WebHooks
no doubt, familiar with web apis, only a minority familiar with webhooks.
webhooks are event callbacks over http. the server/app calls your URL. that’s it.
something happens on their end, they ping a url you gave them.
2. sole champion of webhooks since i coined it in 2006.
before 2006, about 1 or 2 of these names used the pattern. PayPal IPN for example.
since then its exploded, many of these names adopted webhooks either
directly/indirectly because of me, or more importantly because its a good idea.
3. Not a protocol
surprise! they aren’t a protocol or a standard. and they won’t be.
in fact, i’m not sure what i’m doing on this panel -- however! webhooks *are* the core
delivery mechanic of an open protocol you’ve probably have heard of:
4. pubsubhubbub has gotten a lot of coverage and adoption. if you don’t know... (describe).
it was created by brett slatkin and brad fitzpatrick. brad should be on this panel, not me.
can represent pubsubhubbub here, message is about webhooks and why theyre significant.
in fact, let me do that quickly here:
5. Telephone analogy
telephone system makes a good analogy. calls are requests. caller is client, receiver is server.
imagine friend/fam as web services. call to get info, call to tell them info, call to get them to
do something (pick up milk). this is our limited current state of web apis. here’s the problem:
6. The “callback”
There is no way for these people/services to call you back... to call you up at some point and
tell YOU important information.. to tell you they tried to pick up milk, but they were out of
2%.
The best you can do is keep calling them. This is polling. In the real-world, its unacceptable.
Imagine getting a prescription in your busy day (without callbacks).
7. STDIN STDOUT
Program
similarly, imagine unix pipes, without stdout
8. STDIN
Program
it doesn’t work. you need the output that’s not just useful in itself, but can be used as the
input of other programs.
9. API
Web App
today we have regular apis. but they have no way to give us output outside of our requests.
10. API Events
Web App
if web apps had webhook event triggers, something changes in the ecosystem that is really
disproportionate to the simple idea of webhooks. this greater thing is called the evented web.
talking about it at 11:20 in the other room, full of real examples, code, bigger picture, all
that.
11. When something happens, perform
HTTP POST with relevant data to a URL
that the user gives you.
to reiterate, the idea is simple...
12. Why HTTP?
in case its not self evident why this type of infrastructure is not done with xmpp for example:
-simplest thing
-already understood and ubiquitous, webhooks already set precendent
-most important (i would not independently evangelize for 4 years without this):
13. HTTP is the easiest
way to trigger code
thanks to a spec in 1993 called cgi, we not only have the web as an app platform, but http
is essentially rpc. with everything in the cloud, web development being so popular, it’s now
the easiest way to get code to run. write a php script or ruby script. put it in the cloud for
free, instantly. why code??
14. Code can do anything
having arbitrary code run builtin to this pattern means the possibilities are much richer.
instead of having a specific protocol and a client implementation that executes the semantics
of that protocol, you have an open ended system. code can do anything: make phone calls,
order pizza, take advantage of our api ecosystem.
15. Event-driven programming
Writing event handlers
if you take a step back you might see that what this is... is event driven programming.
writing webhooks are writing event handlers. this is big.
16. Event-driven web
“Evented Web”
this is the beginning of a whole new era of web development. programmable web 2.0
where small pieces can make a big difference because you can easily glue apps together.
17. twitter.addEventListener('newfollower', function(event) {
var twitterUser = event.follower;
var friends = facebook.getFriendsNames();
if (twitterUser['name'] in friends) {
twitter.follow(twitterUser);
} else if (twitterUser['following'] > 1000 &&
twitterUser['followers'] < twitterUser['following'] / 2) {
twitter.block(twitterUser);
}
})
18. APIs That Make Things Happen
WebHooks and the Evented Web
11:20 in Technical 2