What are the steps required to access Facebook likes using the Graph API in PHP?

To access Facebook likes using the Graph API in PHP, you need to authenticate your application with Facebook, obtain an access token, and then make a request to the Graph API endpoint for likes on a specific object (e.g., a post or a page). You can then parse the JSON response to extract the likes data.

<?php
$access_token = 'YOUR_ACCESS_TOKEN';
$object_id = 'YOUR_OBJECT_ID'; // e.g., a post ID or a page ID

$url = "https://graph.facebook.com/v13.0/{$object_id}/likes?access_token={$access_token}";

$response = file_get_contents($url);
$data = json_decode($response, true);

$likes_count = $data['summary']['total_count'];

echo "Total likes: " . $likes_count;
?>