small medium large xlarge

Generic-user-small
15 Apr 2009, 02:10
David P (9 posts)

I have read the book’s chapter several times on publishing newsfeeds. I was able to get publish to work via the APIs defined in the book (i.e.: attack_feed()). However, I have not been able to find good documentation on using FB.Connect.showFeedDialog (the best I found was: http://spongetech.wordpress.com/2008/11/17/star-in-a-porno-with-facebook-connect-and-rails/).

Can some suggest where I can find more information on Facebooker and the showFeedDialog method? I know of fb_user_action, but have not had luck using it (and I don’t really understand it).

Thanks in advanced.

Head_pragsmall
15 Apr 2009, 12:57
Mike Mangino (543 posts)

The showFeedDialog method isn’t specific to Facebooker. Most of Facebook connect is just the javascript API. You can find an example project that publishes feeds using the facebooker wrappers at http://github.com/mmangino/fb_connect_example/tree/master

There has also been some discussion of FBConnect on the facebooker google group at http://groups.google.com/facebooker

Generic-user-small
18 May 2009, 04:25
Chris Ye (47 posts)

Hey Mike,

I tried running the app but i got an error as soon as i fired it up. Facebooker.api_key was nil. I’ve never worked with FBconnect before so i’m not to familiar with the config but i assume i need an api key to get it working properly (i set up a test app in fb), it’s just i didn’t see a facebooker.yml file in the config folder. Thoughts?

Processing PagesController#home (for 127.0.0.1 at 2009-05-18 00:07:16) [GET]

NoMethodError (You have a nil object when you didn’t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.+): /vendor/plugins/facebooker/lib/facebooker/rails/controller.rb:93:in fb_cookie_prefix' /vendor/plugins/facebooker/lib/facebooker/rails/controller.rb:97:in fb_cookie_names’ /vendor/plugins/facebooker/lib/facebooker/rails/controller.rb:97:in select' /vendor/plugins/facebooker/lib/facebooker/rails/controller.rb:97:in fb_cookie_names’ /vendor/plugins/facebooker/lib/facebooker/rails/controller.rb:103:in `secure_with_cookies!’

Head_pragsmall
18 May 2009, 17:21
Mike Mangino (543 posts)

You need to create a facebooker.yml file. t is created by default if you install as a plugin. You need to install it if you use a gem.

Generic-user-small
18 May 2009, 20:35
Chris Ye (47 posts)

Thanks again Mike!

Generic-user-small
18 May 2009, 21:41
Chris Ye (47 posts)

Mike,

In the note_sent method in UserPublisher, how do i pass in images data? I tried adding an :images variable into data like this:

def note_sent(note,facebook_session)
  send_as :user_action
  from facebook_session.user
  data :short_note_body=>simple_format(h(truncate(note.body,:length=>20))),:note_body=>simple_format(h(note.body)),:images=>"http://www.google.ca/intl/en_ca/images/logo.gif"
end

but that didn’t work and resulted in the facebook publish popup to error. Do you know of the correct way to add images. Also, how would i set user_message_prompt to replace the default “Write Something…” message?

Finally, will this approach work for publishing feed items with native facebook platform apps?

Thanks in advance.

Head_pragsmall
19 May 2009, 12:10
Mike Mangino (543 posts)

There is an image helper that you pass the image path and the url to: `

  data :images=>[image(image_path("logo.gif"),root_url)]

`

Generic-user-small
19 May 2009, 14:36
Chris Ye (47 posts)

Mike,

adding this into your note_sent method as such:

  def note_sent(note,facebook_session)
    send_as :user_action
    from facebook_session.user
    data :short_note_body=>simple_format(h(truncate(note.body,:length=>20))),:note_body=>simple_format(h(note.body)),:images=>[image(image_path("rails.png"),root_url)]
  end

yields the following error:

TypeError (can't convert nil into String):
    /vendor/plugins/facebooker/lib/facebooker/adapters/adapter_base.rb:8:in `+'
    /vendor/plugins/facebooker/lib/facebooker/adapters/adapter_base.rb:8:in `facebook_path_prefix'
    /vendor/plugins/facebooker/lib/facebooker.rb:72:in `facebook_path_prefix'
Head_pragsmall
19 May 2009, 19:53
Mike Mangino (543 posts)

Do you have a facebooker.yml? It looks like that isn’t set up right.

Generic-user-small
19 May 2009, 22:51
Chris Ye (47 posts)

Here’s what my facebooker.yml file looks like:

development:
  api_key: 76f3dbeea936e438385e47b33d3774d4
  secret_key: 61b9ebd0dfb208b384f3d0ad325cdd3b
  canvas_page_name:
  callback_url: http://localhost:3000/
  pretty_errors: true
  set_asset_host_to_callback_url: true
  tunnel:
    public_host_username: 
    public_host: 
    public_port: 3000
    local_port: 3000

test:
  api_key: 76f3dbeea936e438385e47b33d3774d4
  secret_key: 61b9ebd0dfb208b384f3d0ad325cdd3b
  canvas_page_name: 
  callback_url: http://localhost:3000/
  set_asset_host_to_callback_url: true
  tunnel:
    public_host_username: 
    public_host: 
    public_port: 3000
    local_port: 3000

In my facebook developer app, in setting up a new app, i filled in the Application Name and the Connect URL with http://localhost:3000/ leaving all other fields blank.

I’m fairly certain that I have things set up right as I successfully published the feed to my stream when I tested it without the :images argument in the note_sent method.

Head_pragsmall
20 May 2009, 12:28
Mike Mangino (543 posts)

Okay, my guess is that there is a problem with the defaults. Does it work if you use @root_url(:canvas=>false)@ ? If so, I need to add a fix for the publisher in non-canvas applications.

Generic-user-small
20 May 2009, 14:51
Chris Ye (47 posts)

nope, i get the same error.

I tried to replicate what you did in your connect app example on my canvas app and I wasn’t able to get the facebook feed form to actually pop up. I didn’t get an error but the actual popup didn’t show up after I did an action (as you have it in your notes app). Is there anything I should have modified? This is how my view looks like:

<%= fb_connect_javascript_tag %>
<% init_fb_connect "XFBML","Api" do %>
  <%= fb_user_action(@user_action_to_publish) if @user_action_to_publish%>
<% end %>
Head_pragsmall
20 May 2009, 18:54
Mike Mangino (543 posts)

For a canvas ap there is a different helper, @fb_show_feed_dialog@. You don’t need to include the javascript or the init_fb_connect code

Mike

Generic-user-small
20 May 2009, 20:33
Chris Ye (47 posts)

Thanks Mike!

Worked like a charm. I also tried adding that :images argument on the canvas version of the app. It didn’t error like on the connect app but the javascript feed form never popped up.

Generic-user-small
21 May 2009, 00:35
Chris Ye (47 posts)

just tested, adding (:canvas=>true) after the url fixes the problem and enables you to add images!

Generic-user-small
25 May 2009, 17:28
Chris Ye (47 posts)

Hey Mike,

Another question, would you happen to know how to add custom links to the published feeds after Facebook’s default Comment and Like links?

Thanks again for your all your help so far.

Generic-user-small
25 May 2009, 21:41
Joe Belcher (5 posts)

Put this in your feed template:

<a href='{*event_url*}'>{*event_id*}</a>

You can pass in strings. Eg

 data :event_url => "url_path", :event_id => "some_id", :images=>[image(image_path("logo.gif"),root_url)]

-Joe

Generic-user-small
28 May 2009, 15:19
Chris Ye (47 posts)

Thanks Joe!

You must be logged in to comment