Post to Facebook Page Wall

人盡茶涼 提交于 2019-12-06 16:15:14

问题


I'm just trying to make PHP Connector to Facebook for posting wall posts on a Page. So i'm not trying to post wall post to profile wall or anything else.

I've read some tutorials and manuals and i decided to use Facebook PHP-SDK (from Naitik Shah) https://github.com/facebook/php-sdk/

I've created Facebook App to post wallposts through it. I received appId and api secret. I've added application permissions to my Page and tried example code

$facebook = new Facebook(array(
    'appId' => 'my app id',
    'secret' => 'my api secret',
    'cookie' => false,
    'domain' => 'domain.com'
));

domain.com => domain from which i'm sending api requests next ->

$facebook->getSession();
$token = $facebook->getAccessToken();
$facebook->api('/123456789/feed', array(
    'access_token' => $token,
    'link' => 'http://www.example.com'
));

So i'm trying to post link on wall of page with id 123456789

The request goes through without warnings/errors but nothing is posted in right place and nothing is returned.

Thanks for any idea about this problem.

Used tutorials:

How do you post to the wall on a facebook page (not profile)
http://blog.theunical.com/facebook-integration/5-steps-to-publish-on-a-facebook-wall-using-php/
http://www.moskjis.com/other-platforms/publish-facebook-page-wall-from-your-site
http://tips4php.net/2010/12/automatic-post-to-facebook-from-php-script/


回答1:


$facebook->api('/123456789/feed', 'post', array(
    'access_token' => $token,
    'link' => 'http://www.example.com'
));

Note the 'post' part.

If you look at the source for the API via the link you provided, you'll see:

protected function _graph($path, $method='GET', $params=array()) {
    if (is_array($method) && empty($params)) {
      $params = $method;
      $method = 'GET';
    }

When you don't have 'post' as the second argument and your array as the third, it goes a get




回答2:


If you are getting authorisation errors, make sure you have included the following permission:

 publish_stream

https://developers.facebook.com/docs/reference/api/post/



来源:https://stackoverflow.com/questions/5756474/post-to-facebook-page-wall

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!