What best practices should be followed when retrieving and displaying Facebook posts in PHP?

When retrieving and displaying Facebook posts in PHP, it is important to use the Facebook Graph API to fetch the posts. This involves obtaining an access token and making a request to the API endpoint for the user's posts. Once the posts are retrieved, they can be displayed on a webpage using HTML and CSS.

<?php
$access_token = 'YOUR_ACCESS_TOKEN';
$user_id = 'USER_ID';

$url = "https://graph.facebook.com/{$user_id}/posts?access_token={$access_token}";

$data = file_get_contents($url);
$posts = json_decode($data);

foreach ($posts->data as $post) {
    echo '<div>';
    echo '<h3>' . $post->message . '</h3>';
    echo '<p>' . $post->created_time . '</p>';
    echo '</div>';
}
?>