当新内容发布时,我需要编写一个端点来接收来自 PSHB 集线器的 ping 和提要。我知道 Ruby 上有一些库,例如https://github.com/igrigorik/PubSubHubbub ,但无法弄清楚如何使用如下反应器代码实现 Ruby on Rails 回调:
require "rubygems"
require "pubsubhubbub"
EventMachine.run {
# publish single URL
pub = EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/publish').publish "http://www.test.com/one-feed.atom"
pub.callback { puts "Successfully notified hub." }
pub.errback { puts "Uh oh, something broke: #{pub.response}" }
}
在此先感谢卢卡