如何通过 API (Php SDK) 以管理员身份发布到 Facebookpage?

How to post to Facebookpage as admin via API (Php SDK)?(如何通过 API (Php SDK) 以管理员身份发布到 Facebookpage?)
本文介绍了如何通过 API (Php SDK) 以管理员身份发布到 Facebookpage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我知道如何使用 PHP SDK 通过 API 在 Facebook 页面上发帖,具体操作如下:

$facebook->api('/xxxxxxxxxxx/feed', 'post', array('message'=> 'Hello world!', 'cb' => ''));

其中 xxxxxxxxxxx 是页面 ID ;)

但这样做时,我以我自己的身份发布到该页面,杰米,而不是页面本身(管理员).
那么我如何以管理员/页面的身份而不是我自己的身份发帖?

But doing that, I post to that page as me, Jamie, and not as the Page itself (admin).
So how do I post as Admin/Page instead of myself?

感谢您的时间!

答案(针对懒人):

首先,您需要确保您有权管理用户的页面,例如:

First of all you need to make sure you have access to manage pages for user, ex:

<fb:login-button autologoutlink="true" perms="manage_pages"></fb:login-button>

现在,一旦您获得用户有权访问的每个页面,您还将获得一个特殊的令牌.
PHP SDK 示例:

Now you also gets a special token for every page user have access to once you get them.
PHP SDK Example:

//Get pages user id admin for
$fb_accounts = $facebook->api('/me/accounts');
//$fb_accounts is now an array 
//holding all data on the pages user is admin for, 
//we are interested in access_token 

//We save the token for one of the pages into a variable 
$access_token = $fb_accounts['data'][0]['access_token'];

//We can now update a Page as Admin
$facebook->api('/PAGE_ID/feed', 'post', array('message'=> 'Hello!', 'access_token' => $access_token, 'cb' => ''));

推荐答案

查看关于您的问题的说明:http://developers.facebook.com/docs/api > 授权 > 页面模拟.

Check out this note regarding your question: http://developers.facebook.com/docs/api > Authorization > Page impersonation.

长话短说,您需要 manage_pages 扩展权限.

Long story short, you need the manage_pages extended permission.

顺便说一句,你有没有检查这个 首先?

And btw, have you checked this first ?

这篇关于如何通过 API (Php SDK) 以管理员身份发布到 Facebookpage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)