Get latest Facebook posts of page with PHP SDK

后端 未结 4 1607
傲寒
傲寒 2021-01-31 12:05

The following code is inside a file called facebook_posts.php which I call from my index file like so:

4条回答
  •  执笔经年
    2021-01-31 13:10

    I've found that the most voted solution is way too complicated and only lasts 2 months.

    For me, this is the best solution using an App with Graph API 2.5:

    1.- Create an App.

    2.- Go to: https://developers.facebook.com/tools/explorer/

    • Select your new created app on the right top.
    • Select "Get App Token"

    3.- Copy this "{ACCESS-TOKEN}" (is in the form: number|hash)

    IMPORTANT: (This are not app_id|app_secret!!!)

    4.- Query the URL with CURL:

    • https://graph.facebook.com/{PAGE-ID}/posts?access_token={ACCESS-TOKEN}

    (5).- Equivalent URL:

    • https://graph.facebook.com/{PAGE-ID}/feed?access_token={ACCESS-TOKEN}

    I've put all of this together in a very simple gist:

    https://gist.github.com/biojazzard/740551af0455c528f8a9

提交回复
热议问题