【发布时间】:2023-03-29 16:47:01
【问题描述】:
欢迎提供示例代码,我似乎无法在网上找到任何简单的示例。
【问题讨论】:
-
我最近写了一篇关于这个的文章。您需要获得 extended_access 权限,并且本质上以经过身份验证的用户身份发布,该用户是页面的管理员。 typeoneerror.com/articles/post/…
标签: php facebook facebook-graph-api
欢迎提供示例代码,我似乎无法在网上找到任何简单的示例。
【问题讨论】:
标签: php facebook facebook-graph-api
使用新的Facebook PHP-SDK,很容易做到这一点。
要求:
现在正如我所说,根据您的要求,您可能需要offline_access、manage_pages,但目前这是最简单直接的方法:
下载PHP SDK后,在example.php文件中:
获取publish_stream权限:
<fb:login-button perms="publish_stream"></fb:login-button>
成功验证后,您可以像普通user 个人资料一样发布到页面墙上(并且也使用相同的选项,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);
结果:
请注意,这种方法需要您是页面的管理员。
【讨论】:
在此将 /me/feed/ 更改为您的页面 id,我没有尝试....只是检查
$attachment = array('message' => 'some meesgae',
'name' => 'This is my demo Facebook application!',
'caption' => "Caption of the Post",
'link' => 'mylink.com',
'description' => 'this is a description',
'actions' => array(array('name' => 'Get Search', 'link' => 'google.com')) );
$result = $facebook->api('/me/feed?access_token='.$access_token, 'post', $attachment);
【讨论】:
$access_token?