Presentation for the 34th Ruby-Kansai meeting. Credits: some of the images inside are from the Jeff Lindsay's presentations "Web Hooks and the Programmable World of Tomorrow" and "Using Web Hooks" (see the presenter notes below the slides)
4. Today
• What is this talk about?
• What are webhooks?
• What can they do for me?
• Pros and cons
• Real life usage
20 юни 2009, събота 4
Maybe you already forget the presentation title, so one more time...
13. Real Time Web
• RSS is not enough (SUP)
• XMPP
• Webhooks
20 юни 2009, събота 13
I spoke in Kobe about SUP and XMPP (see my other presentations -
http://www.slideshare.net/zhesto/microblogging-via-xmpp
14. No Polling!
20 юни 2009, събота 14
Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
21. Communications
• Messaging (AMQP): RabbitMQ
• XMPP, Ejabberd, Prosody
• Webhooks
20 юни 2009, събота 21
Webooks can help you with the infrastructure. Some service is too heavy? - move it to
another machine and connect them with webhook. Think about webhooks even when on a
single machine (call by URL, not by function name)
30. SVN Hooks
20 юни 2009, събота 30
Image from the presentation “Using Web Hooks”
31. Hooks
• Subversion pre-commit, post-commit
• Git, Mercurial - they have hooks too
• Rails: :before_save, :after_delete
20 юни 2009, събота 31
32. Unix Philosophy
• do ONE THING and do it well
• programs WORK TOGETHER
• UNIVERSAL INTERFACE (text)
20 юни 2009, събота 32
Insert here more about the webhooks - POST, etc.
example cat | grep | mail -> make this with web too (demo)
33. UNIX pipes
20 юни 2009, събота 33
Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
34. The Web
20 юни 2009, събота 34
Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
35. Web 3D
20 юни 2009, събота 35
There are services creating the web pages (feeds). Now nodes communicate via RSS -
indirect.
Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
36. WebApp pipes?
20 юни 2009, събота 36
Can we make a simple applications and connect them like a pipe?
Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
37. 20 юни 2009, събота 37
Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
39. What are WEBhooks?
webhooks are user defined callback URLs,
that point to a web script to run on a
certain event
20 юни 2009, събота 39
By letting the user specify a URL for various events, the application will POST data to those URLs when the events occur.
Key poins: USER DEFINED, URLs (remote services), RUN ON CERTAIN EVENT (push, no cronjobs etc.)
51. Good
• Well known protocol - HTTP
• code libraries (software)
• infrastructure (hardware)
• Easy for vendors (services)
• Easy for users (consumers)
20 юни 2009, събота 51
53. require ‘net/http’
require ‘json’
class User
def commit(message)
Net::HTTP.post_form(
User.hook_url,
{ :data => message.to_json })
end
end
20 юни 2009, събота 53
For service providers (publishers)
54. require ‘net/smtp’
require ‘json’
require ‘sinatra’
post ‘/hook’ do
data = JSON.parse(params[:data])
# do something with the data
Net::SMTP.start(‘localhost’) do |smtp|
smtp.send_message data[‘message’], from, to
end
end
20 юни 2009, събота 54
For service consumers (subscribers)
55. Bad
• No standard
• Google Code: XML
• GitHub: JSON
• ping.fm - POST parameters
• Security (authentication)
20 юни 2009, събота 55
59. Demo
ping.fm + postbin
ping.fm + switchub (+postbin)
20 юни 2009, събота 59
create new hook on postbin, login to post.fm/custom/ and put there the url. test: web, email,
im?