SDK php,在公共墙中添加新闻



我试图在墙上发布新闻(为所有人),但我的程序不起作用,你能帮我吗?

            $app_config = array(
                'appId' => 'xxxxxxxxxxxxxxxx',
                'secret' => 'xxxxxxxxxxxxxxx',
                'cookie' => true
            );
            $page_config = array(
                'access_token' => 'xxxxxxxxxxxxxxxxxxxxxxxxx',
                'page_id' => 'xxxxxxxxxxxxxxxxxxxxx'
            );

            $facebook = new Facebook($app_config);

            $privacy=array('value' => 'EVERYONE');
            $decri=array('name' => 'See the link', 'link' => 'http://www.xxxxxx.com');
            $description="this is a test";
            $picture="a.png";
            $params = array(
             'access_token' => $page_config['access_token'],
             'name' => $title,
             'caption' => 'www.xxxxxx.com',
             'link' => 'http://www.xxxxxx.com',
             'description' => $description,
             'picture' => $picture,
             'status_type' => 'mobile_status_update',
             'type' => 'status',
             'privacy' => json_encode($privacy),
             'actions' => json_encode($decri)
            );
            $post_id = $facebook->api('/'.$page_config['page_id'].'/feed','post',$params);

但是什么都没有发表,我不明白非常感谢

从你的代码中,我假设你在Facebook页面上发帖,在这种情况下,尤其是链接。

当您尝试发布链接时,不会将其发布到/PAGE_ID/feed,而是将其发布至/PAGE_ID/links(请参阅Facebook文档)。

在您的示例中,您的API请求应该如下所示:

$post_id = $facebook->api('/'.$page_config['page_id'].'/links','post',$params);

此外,$picture应该是一个链路,从httphttps开始。

最后但同样重要的是,请确保您拥有publish_streammanage_pages权限。

与文档相比,您使用的参数略有不同,因此请仔细检查文档——看起来您做的工作太多了。