This assumes you have already created and configured a Facebook App, which you can obtain from the App Dashboard.
Before we can send requests to the Graph API, we need to load our app configuration into the Facebook\Facebook service.
$fb = new Facebook\Facebook([
‘app_id’ => ‘{app-id}’,
‘app_secret’ => ‘{app-secret}’,
‘default_graph_version’ => ‘v2.10’,
]);
You’ll need to replace the {app-id} and {app-secret} with your Facebook app’s ID and secret which can be obtained from the app settings tab.
It’s important that you specify a default_graph_version value as this will give you more control over which version of Graph you want to use. If you don’t specify a default_graph_version, the SDK for PHP will choose one for you and it might not be one that is compatible with your app.
The Facebook\Facebook service ties all the components of the SDK for PHP together. See the full reference for the Facebook\Facebook service.