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 粉丝页
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- PHP - if 语句中的倒序 2021-01-01
