Facebook api post feed on page

131 Views Asked by At

I use Koala gem to manage page. this my code:

@graph = Koala::Facebook::API.new(User.first.access_token)
@accounts = @graph.get_connections("me", "accounts")

#result => 
[{
 "access_token"=>"EAALcOidbyVMBAIwUl2mpp7tiJqklksUDYiAcVClN5MRnlZByBLoHTjT8EkXo6AYibUV8sgJlKECpX3ZB5T2mjMLQRLjCRDsoZAbbFnUaTZBn2UwfGZCk2Hz29gZC7gBPHNKfnBL12BfTXXeWjfsMCil80C9utEigQtJDbrVDqSqspPQwrZC79xxxxxxxx", 
 "category"=>"name", "category_list"=>[{"id"=>"135053632504xxxx", "name"=>"Name"}], 
 "name"=>"page name ", 
 "id"=>"10198676127xxxx", 
 "tasks"=>["ANALYZE", "ADVERTISE", "MODERATE", "CREATE_CONTENT", "MANAGE"]
}]

@page = Koala::Facebook::API.new @accounts.first['access_token']
@page.put_connections("10198676127xxxx", 'feed', :message => "demo feed", :link => "https://placeimg.com/640/480/any")
# or 
# @page.put_wall_post('Making a post in a batch.')


#result 
   Koala::Facebook::ClientError: type: OAuthException, code: 200, message: (#200) If posting to a group, requires app being installed in the group, and \
          either publish_to_groups permission with user token, or both manage_pages \
          and publish_pages permission with page token; If posting to a page, \
          requires both manage_pages and publish_pages as an admin with \
          sufficient administrative permission, x-fb-trace-id: C0oouWcW6eC [HTTP 403]

But in devise.rb, i have config allow scope

config.omniauth :facebook, '80509227996xxxx', 'xxxxxx613c18fb3575a05c52146fxxxx',
                  scope: 'email,publish_pages,manage_pages,read_page_mailboxes,pages_messaging'

Please anyone can tell how to get role manage_pages and publish_pages to post feed to page. Thank You...

0

There are 0 best solutions below