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 粉丝页
基础教程推荐
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
