How can I post to the wall of a Facebook Fan Page using PHP and Open Graph API(如何使用 PHP 和 Open Graph API 发布到 Facebook 粉丝页面的墙上)
问题描述
示例代码很受欢迎,我似乎在网上找不到任何简单的例子.
Sample code is appreciated, I can't seem to find any simple examples of this online.
推荐答案
使用新的 Facebook PHP-SDK,很容易做到这一点.
Using the new Facebook PHP-SDK, it's very easy to accomplish this.
要求:
- 扩展权限,具体取决于您的需求
- 页面 ID
现在正如我所说,根据您的要求,您可能需要 offline_access、manage_pages,但目前这是最简单的直接方法:
Now as I said, depending on your requirements you may need offline_access, manage_pages, but for now this is the simplest straight forward way of doing this:
下载PHP SDK后,在example.php文件中:
After downloading the PHP SDK, and in the example.php file:
获取
publish_stream权限:
<fb:login-button perms="publish_stream"></fb:login-button>
认证成功后,您在页面墙上发布与正常发布相同的方式用户 个人资料(也有相同的选项,消息、图片、链接、名称、标题、描述、来源):
After successful authentication, you post to the page wall the same way you do it for normal user profile (and with the same options too, message, picture, link, name, caption, description, source):
$page_id = '123456789';
$feed_array = array(
'message' => "Hello world!"
);
$page_post = $facebook->api("/$page_id/feed","post",$feed_array);
结果:
请注意,此方法要求您是页面管理员.
这篇关于如何使用 PHP 和 Open Graph API 发布到 Facebook 粉丝页面的墙上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 PHP 和 Open Graph API 发布到 Facebook 粉丝页
基础教程推荐
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- php中的foreach复选框POST 2021-01-01
- php中的PDF导出 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
