[Facebooker-talk] New publishing API

Mike Mangino mmangino at elevatedrails.com
Tue Jul 15 09:54:08 EDT 2008


I've added support for the new message templates. Check out the  
documentation (http://facebooker.rubyforge.org/ and http://facebooker.rubyforge.org/classes/Facebooker/Rails/Publisher.html 
  in particular)

If you've already created a publisher, you will need to re-run the  
script/generate command to create a new migration. By default,  
Facebooker will now keep track of your template ids. To send a message  
using the new API, you'll need to create two methods. The first  
returns the templates. For example:

class MyPublisher < Facebooker::Rails::Publisher
    def publish_action_template
      one_line_story_template "{*actor*} did stuff with {*friend*}"
      one_line_story_template "{*actor*} did stuff"
      short_story_template "{*actor*} has a title {*friend*}",  
render(:partial=>"short_body")
      short_story_template "{*actor*} has a title",  
render(:partial=>"short_body")
      full_story_template "{*actor*} has a title {*friend*}",  
render(:partial=>"full_body")
    end

The name of the method needs to end in _template.

To register this template, you can  call

MyPublisher.register_publish_action

or, to register all templates in a publisher, you can call

MyPublisher.register_all_templates


Facebooker will store the template id and the template name in the  
facebook_templates table.

To send a message from a stored template, you'll need to create  
another method that registers the data:

   def publish_action(f)
     from f
     data :friend=>"Mike"
   end

Then, you can call
MyPublisher.deliver_publish_action

Facebooker will look up the template id automatically.

Let me know if you have any issues with this.

Mike
--
Mike Mangino
http://www.elevatedrails.com





More information about the Facebooker-talk mailing list