Photo_1_small louis 7 posts

page 114 of B7.0:

“We’ll do this by calling AttackPublisher.register_attack_feed. Give this a try in script/console. You should get an integer as a return value.”

i get:

Facebooker::Session::MissingOrInvalidParameter: The small story template is a required parameter, and it must be of type string
<snip />

in my AttackPublisher model, i have the method exactly as listed in the book:

def attack_feed_template
  one_line_story_template "{actor} {result} {defender}" + " with a {move}." 
end

i’m opening script/console, and entering the model + method as listed in the book. i assume no one else is having this issue since i see nothing in these forums. does anyone know how to resolve it? i assume the .register_ method registers the template by the method name in the model, and uses the return value of the method as the ‘string’. am i wrong?

i believe i have the latest version of facebooker (i script/plugin update’ed).

any pointers are much appreciated.

 
Generic-user-small zhao lu 13 posts

Sorry if I’m only pointing out the obvious. Have you tried to put in the short story template as indicated in the error message. the message says small story but I assume it means short story.

def attack_feed_template one_line_story_template “{actor} {result} {defender}” + ” with a {move}.” short_story_template “{actor} engaged in battle.” , “{actor} {result} {defender} with a {move}.”
end

 
Generic-user-small Allen Walker 19 posts

Getting the same thing:

  1. script/console
    Loading development environment (Rails 2.1.0)
    >> ActivityPublisher.register_action
    NoMethodError: undefined method `small_story_template’ for #<activitypublisher:0xb722e798> from /home/slick/meetingup/vendor/plugins/facebooker/lib/facebooker/rails/publisher.rb:239:in `method_missing’ from /home/slick/meetingup/app/models/activity_publisher.rb:12:in `action_template’ from /home/slick/meetingup/vendor/plugins/facebooker/lib/facebooker/rails/publisher.rb:369:in `send’ from /home/slick/meetingup/vendor/plugins/facebooker/lib/facebooker/rails/publisher.rb:369:in `method_missing’ from (irb):1
    >>

And I defined the “small_story_template”

def action_template
  one_line_story_template "{actor} scheduled at {location} on {date}." 
  small_story_template "{actor}", "{actor} scheduled at {location} on {date}." 
  full_story_template "{actor} scheduled at {location} on {date}.", render(:partial => "short_body")
end
 
Generic-user-small zhao lu 13 posts

You are right, I’m getting the same error as well. I also downloaded the lastest tar ball for facebooker from github. Looking at the history the lastest check-in was made about 11 hours ago (it’s 7pm pacific, monday). We’ll probably need to look deeper into the code to see why the out-of-date error is being thrown to us. sigh.

 
Generic-user-small Allen Walker 19 posts

Just to let you know, I was able to publish in my rails web code, just not thru script/console. Don’t ask me why.

 
Generic-user-small zhao lu 13 posts

First of all, congrats!
I can resist asking you why. But would you mind sharing with me, and the forum, how you manage to publish the feed? The only thing I tried is to throw in this line: FacebookGiftsPublisher.deliver_facebook_gift_feed(fb_gift) rescue nil
into the Controller’s create method, right before a flash message and a redirect: flash[:notice] = “Your gift has been sent.” redirect_to new_facebook_gift_path
Since I see the flash message I assume that the deliver method is called. And I think there’s some magic for the deliver method to call facebook_gift_feed method defined in FacebookGiftsPublisher, which uses the feed template that I defined. Am I missing something here?

 
Generic-user-small Allen Walker 19 posts

here are my methods:

class ActivityPublisher < Facebooker::Rails::Publisher

include ApplicationHelper
def action_template
end
app = link_to("Check out the application to find out more!", { :controller => "public", :action => "index" })
one_line_story_template "{actor} will be at {location} in {locale} on {date}. #{ app }"
def action(user, activity)
   send_as :user_action
   from user
   data :location => link_to(activity.location.name, { :controller => "locations", :action => "show", :id => activity.location.id } ),
        :date => activity.scheduled_at.strftime("%A, %b %d"),
        :locale => activity.location.city
end

Publishing in controller:

ActivityPublisher.register_action
ActivityPublisher.deliver_action(current_user.facebook_session.user,activity)

 
Generic-user-small zhao lu 13 posts

thanks for sharing allen! I figured out my problems. There were quite a few:

1. in config/facebooker.yml, i forgot to uncomment this line:
  1. To develop for the new profile design, add the following key..
    api: new
    if you look into sessions.rb in facebooker, it’s using this ENV to determine whether to use new api or not. I think that’s why I was getting the “small story” error coming out of the old api.

2 – 4. all rookie mistakes here and there. but now i can publish feeds.

I noticed that you are publishing actiion_template, which is something i haven’t done but tempted too.

 
Head_small Mike Mangino 148 posts

zhao, Thanks for posting your solution. I had hoped that Facebook would have made api.facebook.com use the new API servers by the time this beta of the book was released. I’ll be making a change in Facebooker to use the new API servers by default.

 
Head_small Mike Mangino 148 posts

I just published the change to Facebooker. If you update the library it will now default to the new API.

Allen, it worked for you via the web earlier because Facebooker detects that a request is coming from the new API and adjusts accordingly. When you ran the same code through script/console, Facebooker defaulted to the old API.

10 posts, 4 voices