Created Date not working
1

Hello everybody! I am working with the Facebook PHP SDK for the first time. I have created the following code so far and works on the whole:

    <?php
        require_once __DIR__ . '/Facebook/autoload.php'; // change path as needed

        $fb = new \Facebook\Facebook([
          'app_id' => 'MY ID',
          'app_secret' => 'MY SECRET CODE',
          'default_graph_version' => 'v2.17',
          'default_access_token' => 'MY TOKEN', // optional
        ]);

        $postData = "";

        try {
            $response = $fb->get('/MY SITE ID/feed?fields=full_picture,message,permalink_url.limit(10)','MY TOKEN');
        } catch(Facebook\Exceptions\FacebookResponseException $e) {
            echo 'Graph returned an error: ' . $e->getMessage();
            exit;
        } catch(Facebook\Exceptions\FacebookSDKException $e) {
            echo 'Facebook SDK returned an error: ' . $e->getMessage();
            exit;
        }

        $graphNode = $response->getGraphEdge();


        if (! empty($graphNode)) {
            foreach ($graphNode as $k => $v) {

                ?>
                <div class="grid-item pNormal" data-timestamp="<?php echo $graphNode[$k]["created_time"]; ?>">
                    <div class="grid-item-content">
                        <article id="post-<?php echo $graphNode[$k]["id"]; ?>">
                            <a href="<?php echo $graphNode[$k]["permalink_url"]; ?>"> 
                                <div class="grid-item-thumbnail">
                                    <img src="<?php echo $graphNode[$k]["full_picture"]; ?>" alt="" class="img-fluid">    
                                </div>
                                <header class="sl-entry-header">
                                    Musterüberschrift
                                </header>
                                <div class="sl-entry-content">
                                    <?php echo $graphNode[$k]["message"]; ?>
                                </div>
                                <div class="pCats">
                                    Musterkategorien
                                </div>
                            </a>
                        </article>
                    </div>
                </div>
                <?php
            }
        }
        ?>

With "" I would like to output the current timestamp of the post. However, the field is always empty for me and nothing is simply output.

Can anyone help me further?

Oliver
Asked about 4 years ago
Selected Answer
1

Add created_time to your list of fields to request

January 16 at 5:58 AM
Lars