Hey i am trying to implemet facebook feed post to user’s facebook wall
functionality from my web application/website. i tried a lot but still
result less. Plz tell me which is the best way to implement facebook
feed post in user’s profle. I am using facebooker.
I am working in rails 2.3.8 verison. install Facebooker Gem as i also
need to fconnect functionality.
- Here is my dashboard controller … after login through fconnect we
redirect user to “show” action of dashboard controller.
class DashboardsController < ApplicationController
#before_filter :login_required
layout ‘index’
#--------- Creatting sub class ----------
class FacebookPublisher < Facebooker::Rails::Publisher
def publish_pg_template
one_line_story_template “{actor} created/updated: restro”
short_story_template "{actor} created/updated: restro data! ",
“testing”
end
def publish_pg(pg,facebook_session)
send_as :user_action
from facebook_session.user
data :actor => facebook_session.user.first_name
end
end
#--------- End sub class ----------
def show
@user = facebook_session.user
#-----------------------------------------------
action = Facebooker::Feed::TemplatizedAction.new
action.page_actor_id = “104646262908753”
action.title_template = “test from {actor} did something”
@user.publish_templatized_action(action)
#-----------------------------------------------
#-----------------------------------------------
#f = Facebooker::Session.create
#f.post ‘facebook.stream.publish’, :uid => @user.id, :message =>
‘test4’
#-----------------------------------------------
#-----------------------------------------------
flash[:user_action_to_publish] =
FacebookPublisher.create_publish_pg(@user,session[:facebook_session])
#-----------------------------------------------
#-----------------------------------------------
puts @user.id
fb_session = Facebooker::Session.create
fb_session.auth_token = @user.session.auth_token
fb_session.post(“facebook.feed.publishTemplatizedAction”, :target_ids
=>
“”, :title_template => “Testing a News Feed post on a Page posted by
{actor}”, :title_data => “{}”, :body_template => “Check it out yo says
{name}.”, :body_data => “{“name”: “cbq”}”, :body_general => “Here is
the
body.”, :page_actor_id => “104646262908753”)
#-----------------------------------------------
respond_to do |format|
format.html
end
end
end
Note :-> all the code between
“#-----------------------------------------------” are different
approaches to post feed into user’s or pages wall but i am still
resultless.
- Here is my layout file data.
<%= stylesheet_link_tag ‘application’ %>
<%= javascript_include_tag :defaults %>
<%= fb_connect_javascript_tag %>
<% init_fb_connect “XFBML” %>
<% init_fb_connect “XFBML”,“Api” do %>
<%= fb_user_action(flash[:user_action_to_publish]) if
flash[:user_action_to_publish] %>
<% end %>
<%= flash[:notice] %>
<%= yield %>- Here is my view file for “show” function with just a logout link.
<%= link_to “Sign Out”, user_session_path, :method => :delete
-%>
Also plz tell me weather should i have to go for another approach
instead of facebooker. should i have to update the rails version etc
etc.