| Class | Facebooker::Rails::Publisher |
| In: |
lib/facebooker/rails/publisher.rb
|
| Parent: | Object |
ActionMailer like module for publishing Facbook messages
To use, create a subclass and define methods Each method should start by calling send_as to specify the type of message Valid options are :action, :templatized_action, :story, :email and :notification
Below is an example of each type
class TestPublisher < Facebooker::Rails::Publisher
# Action is published using the session of the from user
def action(f)
send_as :action
from f
title "Action Title"
body "Body FBML here #{fb_name(f)} #{link_to "text",new_invitation_url}"
end
# Templatized Action uses From
def templatized_action(f)
send_as :templatized_action
from f
title_template "Templatized Action Title {name}"
title_data :name=>"Mike"
end
# story is published to the story of the to user
def story(to)
send_as :story
recipients to
title 'Story Title'
end
def notification(to,f)
send_as :notification
recipients to
from f
fbml "Not"
end
def email(to,f)
send_as :email
recipients to
from f
title "Email"
fbml 'text'
text fbml
end
# This will render the profile in /users/profile.erb
# it will set @user to user_to_update in the template
# The mobile profile will be rendered from the app/views/test_publisher/_mobile.erb
# template
def profile_update(user_to_update,user_with_session_to_use)
from user_with_session_to_use
to user_to_update
profile render(:action=>"/users/profile",:assigns=>{:user=>user_to_update})
profile_action "A string"
mobile_profile render(:partial=>"mobile",:assigns=>{:user=>user_to_update})
end
To send a message, use ActionMailer like semantics
TestPublisher.deliver_action(@user)
For testing, you may want to create an instance of the underlying message without sending it
TestPublisher.create_action(@user)
will create and return an instance of Facebooker::Feeds::Action
Publisher makes many helpers available, including the linking and asset helpers
| _body | [RW] |