Sample code is appreciated, I can't seem to find any simple examples of this online.
Asked
Active
Viewed 4,493 times
3
-
I wrote an article about this recently. You need to get extended_access permission and essentially post as an authenticated user that is an admin of the page. http://www.typeoneerror.com/articles/post/permanent-facebook-sessions-and-posting-as-a-page – typeoneerror Jan 19 '11 at 05:49
2 Answers
3
Using the new Facebook PHP-SDK, it's very easy to accomplish this.
Requirements:
- Extended Permissions, depending on your needs
- Page ID
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:
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);
Result:
Please note that this approach requires you being an administrator of the page.

ifaour
- 38,035
- 12
- 72
- 79
-
-
Many people can have different roles on a page, what roles are allowed to give an app the permission to manage the facebook page. – Shubham Aggarwal Sep 06 '16 at 06:44
0
in this change the /me/feed/ to your page id, I did't try....Just check
$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);

Damodaran
- 10,882
- 10
- 60
- 81