Skip to content

Instantly share code, notes, and snippets.

@reducedhackers
Created September 18, 2017 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save reducedhackers/2613fc9de2c39333d7d9b235938347b6 to your computer and use it in GitHub Desktop.
Save reducedhackers/2613fc9de2c39333d7d9b235938347b6 to your computer and use it in GitHub Desktop.
Getting the most recent posts from a Public Page .
<?php
/*
This may be a long way around a short problem .. but
The PHP SDK from Facebook :
git clone https://github.com/facebook/php-graph-sdk.git
Im using my own FB App to give me a Token/Secret
/*
require_once '<path to git clone https://github.com/facebook/php-graph-sdk.git >/php-graph-sdk/src/Facebook/autoload.php';
$APPID="1234567890987532";
$APPSECRET="abcdefghij123453212sd";
$PAGEID="pagenamefromurl";
$fb = new Facebook\Facebook([
'app_id' => $APPID,
'app_secret' => $APPSECRET,
]);
$fb->setDefaultAccessToken($fb->getApp()->getAccessToken());
$request = $fb->get('/'. $PAGEID . "/posts?limt=5");
echo print_r($request);
?>
@reducedhackers
Copy link
Author

Based around ..
https://developers.facebook.com/docs/php/Facebook/5.0.0

get()

public Facebook\FacebookResponse get(
string $endpoint,
string|AccessToken|null $accessToken,
string|null $eTag,
string|null $graphVersion
)
Sends a GET request to Graph and returns a Facebook\FacebookResponse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment