Using Koala to post a user's page on the wall from an app
I already have a facebook app where users are already using it. I already have the option to publish to my walls through Koala.
@oauth = Koala::Facebook::OAuth.new options[:fb_application_id], options[:fb_secret_key]
@graph = Koala::Facebook::API.new @oauth.get_app_access_token
@graph.put_connections(fb_user_id, "feed", :message => 'sample message')
Now I want to add a function where I can get the user's page id and allow my application to publish that page.
Something like below:
@oauth = Koala::Facebook::OAuth.new options[:fb_application_id], options[:fb_secret_key]
@graph = Koala::Facebook::API.new @oauth.get_app_access_token
@graph.put_connections 'the_page_id', 'feed', :message => 'this is a message to post'
The result of the line above:
Koala::Facebook::ClientError: type: OAuthException, code: 200, message: (#200) The user hasn't authorized the application to perform this action [HTTP 403]
I have already set the "manage_pages publish_actions publish_stream" permission in the app side and when the user has authorized the app.
Please, help.
Thank!
+3
source to share
2 answers
The following actions can help,
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, ENV['KEY'], ENV['SECRET'], scope: 'manage_pages publish_pages publish_actions'
end
-
manage_pages
gives you access to pages operated by the user. -
publish_pages
gives you the privilege to publish as a page -
publish_actions
gives you the privilege to publish as user
PS: publish_stream
deprecated.
+4
source to share