ruby-on-rails - 页面上的 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 以将提要发布到页面。谢谢你...
解决方案
推荐阅读
- python - 将前缀表示法中的这些嵌套字符串转换为元组的最佳方法是什么?
- typo3 - 带有来自页面资源的图像的流体菜单元素?
- javascript - 有一种情况我需要将对象数组转换为数组数组
- angular - 如何使用 Angular 获取客户端机器的 MAC 地址
- c - 在为 arm 进行交叉编译时,是否有特定的编译器标志可以使用 gcc sync-builtins?
- javascript - 扩展 D3 图表以从 HTML 页面添加工具提示
- javascript - 世博会获取返回网络请求错误或承诺对象的链接
- python - 在干净的 anaconda 安装上使用 statsmodels 时出现 AttributeError
- swift - 如何在 iOS13 中更改 Searchbar 的占位符字体和大小
- python - 从 for 循环中触发协程