Extremely simple PubSubHubbub application with Ruby and Sinatra

February 10th, 2011

I’m starting to work on my project that is supposed to use PubSubHubbub. I had some difficulty understanding it as I found documentation inadequate. I have managed to get this simple app to work with a public Hub (http://pubsubhubbub.appspot.com/).

All it does is confirm all subscription requests, and when it recieves data it prints it on screen. It uses Sinatra for handling http requests. It’s not much but maybe someone will find it useful.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'rubygems'
require 'sinatra'
 
#accepting all requests
get '/' do
 
	puts "response: '"+ params['hub.challenge'] + "'"
 
	content_type 'text/plain', :charset => 'utf-8'
	params['hub.challenge']
end
 
#accepting messages
post '/' do
	puts request.body.read
end

blog comments powered by Disqus