SlideShare a Scribd company logo
1 of 63
Download to read offline
Webhooks
                      glue for the Web




20 юни 2009, събота                      1
• :
                 •
                 • : Software Engineer
                 • Contact: xmpp: //zh@jabber.jp

20 юни 2009, събота                                2
20 юни 2009, събота   3
20 юни 2009, събота   4
•

                 • webhooks                 ?

                 •               ?

                 •

                 • Real life usage

20 юни 2009, събота                                                    5

Maybe you already forget the presentation title, so one more time...
?




20 юни 2009, събота       6
Webhooks
                      glue for the Web

20 юни 2009, събота                      7
?
20 юни 2009, събота       8
Glue (   )?
20 юни 2009, събота                 9
Web 3.0
20 юни 2009, събота                        10

Don’t worry. We will talk about web :)
Web x.0?


                 • Web 1.0 - static
                 • Web 2.0 - dynamic? social?
                 • Web 3.0 - real time?



20 юни 2009, събота                             11

Google Wave, iPhone push notifications
Web 3.0


                 • Real Time
                 • Does it scale?
                 • PubSub



20 юни 2009, събота                      12
Real Time
20 юни 2009, събота               13
Real Time Web


                 • RSS                 (SUP)

                 • XMPP
                 • Webhooks



20 юни 2009, събота                                                14

I spoke in Kobe about SUP and XMPP (see my other presentations -
http://www.slideshare.net/zhesto/microblogging-via-xmpp
No Polling!
20 юни 2009, събота                                                              15

Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
Real Time
20 юни 2009, събота               16
Does it scale?



20 юни 2009, събота                                                                           17

Recently working a lot with EC2 - pay per use, scale easy - instant start/stop of instances
Clouds...



20 юни 2009, събота               18
Clouds?
20 юни 2009, събота             19
cloud!
20 юни 2009, събота            20
Communications
20 юни 2009, събота                    21
Communications


                 • Messaging (AMQP): RabbitMQ
                 • XMPP, Ejabberd, Prosody
                 • Webhooks



20 юни 2009, събота                                                                     22

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)
PubSub



20 юни 2009, събота            23
Publishers
20 юни 2009, събота                24
Subscribers
20 юни 2009, събота                 25
Publishers and Subscribers
20 юни 2009, събота                        26
Watercoolr

                 •PubSub
                 •Webhooks
                 •Ruby

                      http://github.com/jcapote/watercoolr/

          http://github.com/zh/watercoolr/
20 юни 2009, събота                                           27
PubSubHubBub
                  http://code.google.com/p/pubsubhubbub/


20 юни 2009, събота                                        28
Webhooks                              ?
20 юни 2009, събота                                             29

Image from the presentation “Using Web Hooks”
I keep repeating webhooks, webhooks,... So what are they?
Captain Hook
20 юни 2009, събота                  30
SVN Hooks
20 юни 2009, събота                             31

Image from the presentation “Using Web Hooks”
Hooks


                 • Subversion pre-commit, post-commit
                 • Git, Mercurial -

                 • Rails: :before_save, :after_delete



20 юни 2009, събота                                     32
20 юни 2009, събота   33
Unix Philosophy


                 • do ONE THING and do it well
                 • programs WORK TOGETHER
                 • UNIVERSAL INTERFACE (text)



20 юни 2009, събота                                          34

Insert here more about the webhooks - POST, etc.
example cat | grep | mail -> make this with web too (demo)
UNIX pipes
20 юни 2009, събота                                                              35

Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
The Web
20 юни 2009, събота                                                              36

Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
Web 3D
20 юни 2009, събота                                                                  37

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”
WebApp pipes?
20 юни 2009, събота                                                              38

Can we make a simple applications and connect them like a pipe?
Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
20 юни 2009, събота                                                              39

Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
POST /service data={ 'message':'hey guys!' }




20 юни 2009, събота                               40
20 юни 2009, събота   41
What are WEBhooks?

              webhooks are user defined callback URLs,
                that point to a web script to run on a
                            certain event




20 юни 2009, събота                                                                                                         42

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.)
User defined
20 юни 2009, събота                 43
URLs = remote
20 юни 2009, събота                   44
register URL
20 юни 2009, събота                             45

Image from the presentation “Using Web Hooks”
get notification
20 юни 2009, събота                             46

Image from the presentation “Using Web Hooks”
Why?



20 юни 2009, събота          47
Service Integration
20 юни 2009, събота                         48
Flexibility
20 юни 2009, събота                 49
Customization
20 юни 2009, събота                                                              50

Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
Webhooks


                 • Jeff Lindsay
                 • http://blogrium.com/?p=70
                 • http://webhooks.pbworks.com/
                 • http://blog.webhooks.org/



20 юни 2009, събота                               51
Webhooks


               • Amazon have Merchant Callback API
               • PayPal (Instant Payment Notification)
               • GitHub and Google Code



20 юни 2009, събота                                     52
Good and bad
20 юни 2009, събота                  53
• Well known protocol - HTTP
                      • code libraries (software)
                      • infrastructure (hardware)
                 • Easy for vendors (services)
                 • Easy for users (consumers)


20 юни 2009, събота                                 54
20 юни 2009, събота   55
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, събота                              56

For service providers (publishers)
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, събота                                           57

For service consumers (subscribers)
•

                      • Google Code: XML
                      • GitHub: JSON
                      • ping.fm - POST

                 •                (authentication)


20 юни 2009, събота                                  58
Real Life Usage



20 юни 2009, събота                     59
?


                 • http://heroku.com/ - Ruby
                 • GAE - Python, Java, JRuby
                 • http://scriptlets.org/ - Python, JS
                 • PHP - almost everywhere



20 юни 2009, събота                                      60
• GitHub - RunCodeRun
                 • http://ping.fm/ - IM, email, Skype
                 • http://postbin.org/ - debug
                 • SwitchHub, TarPipe
                 • http://superfeedr.com/ - RSS
                 • http://bot.im/ - IMified XMPP bot

20 юни 2009, събота                                     61
Demo
                            ping.fm + postbin
                      ping.fm + switchub (+postbin)




20 юни 2009, събота                                                                         62

create new hook on postbin, login to post.fm/custom/ and put there the url. test: web, email,
im?
20 юни 2009, събота   63

More Related Content

More from Stoyan Zhekov

Padrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraPadrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraStoyan Zhekov
 
Deployment on Heroku
Deployment on HerokuDeployment on Heroku
Deployment on HerokuStoyan Zhekov
 
Foreman - Process manager for applications with multiple components
Foreman - Process manager for applications with multiple componentsForeman - Process manager for applications with multiple components
Foreman - Process manager for applications with multiple componentsStoyan Zhekov
 
Social Network for spare parts
Social Network for spare partsSocial Network for spare parts
Social Network for spare partsStoyan Zhekov
 
Using XMPP Presence stanzas for real-time parking information
Using XMPP Presence stanzas for real-time parking informationUsing XMPP Presence stanzas for real-time parking information
Using XMPP Presence stanzas for real-time parking informationStoyan Zhekov
 
Websockets with ruby
Websockets with rubyWebsockets with ruby
Websockets with rubyStoyan Zhekov
 
Webhooks - glue for the web
Webhooks - glue for the webWebhooks - glue for the web
Webhooks - glue for the webStoyan Zhekov
 
Microblogging via XMPP (japanese)
Microblogging via XMPP (japanese)Microblogging via XMPP (japanese)
Microblogging via XMPP (japanese)Stoyan Zhekov
 
Ruby off Rails (japanese)
Ruby off Rails (japanese)Ruby off Rails (japanese)
Ruby off Rails (japanese)Stoyan Zhekov
 

More from Stoyan Zhekov (11)

Padrino - the Godfather of Sinatra
Padrino - the Godfather of SinatraPadrino - the Godfather of Sinatra
Padrino - the Godfather of Sinatra
 
Sequel
SequelSequel
Sequel
 
Deployment on Heroku
Deployment on HerokuDeployment on Heroku
Deployment on Heroku
 
Foreman - Process manager for applications with multiple components
Foreman - Process manager for applications with multiple componentsForeman - Process manager for applications with multiple components
Foreman - Process manager for applications with multiple components
 
Social Network for spare parts
Social Network for spare partsSocial Network for spare parts
Social Network for spare parts
 
Using XMPP Presence stanzas for real-time parking information
Using XMPP Presence stanzas for real-time parking informationUsing XMPP Presence stanzas for real-time parking information
Using XMPP Presence stanzas for real-time parking information
 
Websockets with ruby
Websockets with rubyWebsockets with ruby
Websockets with ruby
 
EventMachine
EventMachineEventMachine
EventMachine
 
Webhooks - glue for the web
Webhooks - glue for the webWebhooks - glue for the web
Webhooks - glue for the web
 
Microblogging via XMPP (japanese)
Microblogging via XMPP (japanese)Microblogging via XMPP (japanese)
Microblogging via XMPP (japanese)
 
Ruby off Rails (japanese)
Ruby off Rails (japanese)Ruby off Rails (japanese)
Ruby off Rails (japanese)
 

Webhooks - glue for the web (japanese)

  • 1. Webhooks glue for the Web 20 юни 2009, събота 1
  • 2. • : • • : Software Engineer • Contact: xmpp: //zh@jabber.jp 20 юни 2009, събота 2
  • 3. 20 юни 2009, събота 3
  • 4. 20 юни 2009, събота 4
  • 5. • webhooks ? • ? • • Real life usage 20 юни 2009, събота 5 Maybe you already forget the presentation title, so one more time...
  • 6. ? 20 юни 2009, събота 6
  • 7. Webhooks glue for the Web 20 юни 2009, събота 7
  • 8. ? 20 юни 2009, събота 8
  • 9. Glue ( )? 20 юни 2009, събота 9
  • 10. Web 3.0 20 юни 2009, събота 10 Don’t worry. We will talk about web :)
  • 11. Web x.0? • Web 1.0 - static • Web 2.0 - dynamic? social? • Web 3.0 - real time? 20 юни 2009, събота 11 Google Wave, iPhone push notifications
  • 12. Web 3.0 • Real Time • Does it scale? • PubSub 20 юни 2009, събота 12
  • 13. Real Time 20 юни 2009, събота 13
  • 14. Real Time Web • RSS (SUP) • XMPP • Webhooks 20 юни 2009, събота 14 I spoke in Kobe about SUP and XMPP (see my other presentations - http://www.slideshare.net/zhesto/microblogging-via-xmpp
  • 15. No Polling! 20 юни 2009, събота 15 Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
  • 16. Real Time 20 юни 2009, събота 16
  • 17. Does it scale? 20 юни 2009, събота 17 Recently working a lot with EC2 - pay per use, scale easy - instant start/stop of instances
  • 18. Clouds... 20 юни 2009, събота 18
  • 19. Clouds? 20 юни 2009, събота 19
  • 20. cloud! 20 юни 2009, събота 20
  • 22. Communications • Messaging (AMQP): RabbitMQ • XMPP, Ejabberd, Prosody • Webhooks 20 юни 2009, събота 22 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)
  • 23. PubSub 20 юни 2009, събота 23
  • 24. Publishers 20 юни 2009, събота 24
  • 25. Subscribers 20 юни 2009, събота 25
  • 26. Publishers and Subscribers 20 юни 2009, събота 26
  • 27. Watercoolr •PubSub •Webhooks •Ruby http://github.com/jcapote/watercoolr/ http://github.com/zh/watercoolr/ 20 юни 2009, събота 27
  • 28. PubSubHubBub http://code.google.com/p/pubsubhubbub/ 20 юни 2009, събота 28
  • 29. Webhooks ? 20 юни 2009, събота 29 Image from the presentation “Using Web Hooks” I keep repeating webhooks, webhooks,... So what are they?
  • 30. Captain Hook 20 юни 2009, събота 30
  • 31. SVN Hooks 20 юни 2009, събота 31 Image from the presentation “Using Web Hooks”
  • 32. Hooks • Subversion pre-commit, post-commit • Git, Mercurial - • Rails: :before_save, :after_delete 20 юни 2009, събота 32
  • 33. 20 юни 2009, събота 33
  • 34. Unix Philosophy • do ONE THING and do it well • programs WORK TOGETHER • UNIVERSAL INTERFACE (text) 20 юни 2009, събота 34 Insert here more about the webhooks - POST, etc. example cat | grep | mail -> make this with web too (demo)
  • 35. UNIX pipes 20 юни 2009, събота 35 Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
  • 36. The Web 20 юни 2009, събота 36 Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
  • 37. Web 3D 20 юни 2009, събота 37 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”
  • 38. WebApp pipes? 20 юни 2009, събота 38 Can we make a simple applications and connect them like a pipe? Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
  • 39. 20 юни 2009, събота 39 Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
  • 40. POST /service data={ 'message':'hey guys!' } 20 юни 2009, събота 40
  • 41. 20 юни 2009, събота 41
  • 42. What are WEBhooks? webhooks are user defined callback URLs, that point to a web script to run on a certain event 20 юни 2009, събота 42 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.)
  • 43. User defined 20 юни 2009, събота 43
  • 44. URLs = remote 20 юни 2009, събота 44
  • 45. register URL 20 юни 2009, събота 45 Image from the presentation “Using Web Hooks”
  • 46. get notification 20 юни 2009, събота 46 Image from the presentation “Using Web Hooks”
  • 47. Why? 20 юни 2009, събота 47
  • 48. Service Integration 20 юни 2009, събота 48
  • 49. Flexibility 20 юни 2009, събота 49
  • 50. Customization 20 юни 2009, събота 50 Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”
  • 51. Webhooks • Jeff Lindsay • http://blogrium.com/?p=70 • http://webhooks.pbworks.com/ • http://blog.webhooks.org/ 20 юни 2009, събота 51
  • 52. Webhooks • Amazon have Merchant Callback API • PayPal (Instant Payment Notification) • GitHub and Google Code 20 юни 2009, събота 52
  • 53. Good and bad 20 юни 2009, събота 53
  • 54. • Well known protocol - HTTP • code libraries (software) • infrastructure (hardware) • Easy for vendors (services) • Easy for users (consumers) 20 юни 2009, събота 54
  • 55. 20 юни 2009, събота 55
  • 56. 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, събота 56 For service providers (publishers)
  • 57. 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, събота 57 For service consumers (subscribers)
  • 58. • Google Code: XML • GitHub: JSON • ping.fm - POST • (authentication) 20 юни 2009, събота 58
  • 59. Real Life Usage 20 юни 2009, събота 59
  • 60. ? • http://heroku.com/ - Ruby • GAE - Python, Java, JRuby • http://scriptlets.org/ - Python, JS • PHP - almost everywhere 20 юни 2009, събота 60
  • 61. • GitHub - RunCodeRun • http://ping.fm/ - IM, email, Skype • http://postbin.org/ - debug • SwitchHub, TarPipe • http://superfeedr.com/ - RSS • http://bot.im/ - IMified XMPP bot 20 юни 2009, събота 61
  • 62. Demo ping.fm + postbin ping.fm + switchub (+postbin) 20 юни 2009, събота 62 create new hook on postbin, login to post.fm/custom/ and put there the url. test: web, email, im?
  • 63. 20 юни 2009, събота 63