Facebook PHP SDK 3.0 - How to get my page wall posts at any time?

前端 未结 2 1447
生来不讨喜
生来不讨喜 2021-01-03 12:25

I have been trying to read the news feed from a page that I have using an app that I\'m coding.

Now I have had some issues trying to do this using the PHP SDK 3.0.

2条回答
  •  甜味超标
    2021-01-03 13:13

    To access the posts of a page, it is /feed and not /post. Then, here is the correct version of your example :

    require "facebook.php";
    $facebook = new Facebook(array(
        'appId'  => YOUR_APP_ID,
        'secret' => YOUR_APP_SECRET,
    ));
    
    $pageFeed = $facebook->api(THE_PAGE_ID . '/feed');
    

    Then the array $pageFeed will contain the 25 latest posts and links to navigation :

    Array(
        [data] => Array(
            [0] => Array(
                [id] => ...
                [from] => ...
                [to] => ...
                [message] => ...
                [icon] => ...
                [type] => ...
                [application] => ...
                [created_time] => ...
                [updated_time] => ...
            )
            [1] => ...
            [2] => ...
            ...
            [24] => ...
        )
        [paging] => Array(
            [previous] => https://...
            [next] => https://...
        )
    )
    

    Hope that helps !

提交回复
热议问题