Using the MessagePub gem

13 03 2009

In my last post, I showed you how you can use ActiveResource to interact with MessagePub. I’ve also wrote a gem that makes interacting with MessagePub even easier.

To get started, install the gem:

sudo gem install messagepub

Code is worth a thousand words so I’ll leave you with this code sample:

require 'rubygems'
require 'messagepub'

client = MessagePub::Client.new('YOUR API KEY')

notification = MessagePub::Notification.new
notification.body = 'So and so has added you as a friend.'
notification.escalation = 20
notification.add_recipient(MessagePub::Recipient.new(:position => 1, :channel => 'twitter', :address => 'joetheplumber'))
notification.add_recipient(MessagePub::Recipient.new(:position => 2, :channel => 'email', :address => 'joe@example.com'))

client.create!(notification)

The gem is on RubyForge, the code on github and we have a Google Group where you can ask questions.


Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.