October 26, 2024
Chicago 12, Melborne City, USA
PHP

get post from facebook page


I had a php code which gets the last 3 posts from my Facebook page.
Facebook API Version 15.

Now, version 15 is not available anymore, so I updated my Facebook App (developer portal) to version 21.

This is my code:

// GET FEED
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); 
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/v21.0/me/feed?'.http_build_query(
    array(
                "limit"   =>   "3",
        "fields"  =>   "attachments,created_time",
        "access_token"  => "XXX"
    )));


$response = json_decode(curl_exec($ch),true);
curl_close($ch);

echo '<pre>';
print_r($response);

Response

Array
(
    [data] => Array
        (
        )
)

Where is my mistake?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video