第34回 Ruby/Rails勉強会@関西.
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)
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”
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)
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”
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.)
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
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?