如何使用PHP和Open Graph API发布到Facebook粉丝专页的墙壁 [英] How can I post to the wall of a Facebook Fan Page using PHP and Open Graph API
问题描述
示例代码是值得赞赏的,我似乎找不到这个在线的任何简单的例子。
Facebook PHP-SDK ,很容易实现这一点。
要求:
-
- 页面ID
/ ol> -
获取
publish_stream
权限:< fb:login-button perms =publish_stream>< / fb:login-按钮>
-
认证成功后,您以同样的方式向页面墙发布正常用户个人资料(以及相同的选项,
$ page_id = '123456789';
$ feed_array = array(
'message'=>Hello world!
);
$ page_post = $ facebook-> api(/ $ page_id / feed,post,$ feed_array);
- Extended Permissions, depending on your needs
- Page ID
Acquire the
publish_stream
permission:<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);
现在正如我所说,根据您的要求,您可能需要 offline_access
, manage_pages
,但现在这是最简单的直接做法:
下载PHP SDK后,在$ code> example.php file:
结果:
请注意,这个方法要求您作为页面的管理员。
Sample code is appreciated, I can't seem to find any simple examples of this online.
Using the new Facebook PHP-SDK, it's very easy to accomplish this.
Requirements:
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:
After downloading the PHP SDK, and in the example.php
file:
Result:
Please note that this approach requires you being an administrator of the page.
这篇关于如何使用PHP和Open Graph API发布到Facebook粉丝专页的墙壁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!