首页 > 解决方案 > 页面上的 Facebook api 发布提要

问题描述

我使用 Koala gem 来管理页面。这是我的代码:

@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]

但是在devise.rb,我有配置允许范围

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

请任何人都可以告诉如何获得角色 manage_pages 和 publish_pages 以将提要发布到页面。谢谢你...

标签: ruby-on-railsfacebookkoala

解决方案


推荐阅读