I am exploring the Facebook API for a couple of days now, because I am trying to get leads from my Facebook page using Webhooks with Lead Ads.
After reading a bunch of articles and Facebook documentation I noticed that for a lot functions in the documentation you see a $session
variable defined (for example here and here).
Because I want to get the leads from my Facebook page I started following this article, which explains how to get real time lead updates from Facebook.
The article starts with setting up a request for receiving the app subscriptions for your Facebook page. But I directly came into trouble with creating the session, because it looks like the FacebookSession
class does not exists in the current Facebook SDK anymore.
How do I need to setup this session? Because I can not find anywhere in the SDK files the FacebookSession class, so I think in the mean time this is changed.
require_once __DIR__ . '/facebook-sdk-v5/autoload.php';
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
// I cannot find this class anywhere
$session = new FacebookSession('<APP_ACCESS_TOKEN>');
$request = new FacebookRequest(
$session,
'POST',
'/<APP_ID>/subscriptions',
array(
'object' => 'page',
'callback_url' => '<YOUR_CALLBACK_URL>',
'fields' => 'conversations',
'verify_token' => '<YOUR_VERIFY_TOKEN>',
)
);
$response = $request->execute();
I get an 500 server error with the following message:
Fatal error: Class 'Facebook\FacebookSession' not found in ...