問題描述
示例代碼很受歡迎,我似乎在網上找不到任何簡單的例子.
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 粉絲頁面的墻上的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!