0

I'm trying to get an overview of all the posts op a facebook page in my website. But I get a Invalid appsecret_proof provided message.When I try it in the Graph API Explorer everything works fine but when I try it in my testplace it doesn't work. I'm wondering if there is just some kind of internetconnection problem or I've done something wrong with my code/token.

<?php
  require_once 'application/third_party/Facebook/autoload.php';
  $fb = new \Facebook\Facebook([
    'app_id' => '<app-id>',
    'app_secret' => '<app-secret>',
    'default_graph_version' => 'v2.10',
  ]);

  try {
    // Returns a `FacebookFacebookResponse` object
    $response = $fb->get(
      '/<page-id>/feed',
      '{<access-token>}'
    );
  } catch(FacebookExceptionsFacebookResponseException $e) {
    echo 'Graph returned an error: ' . $e->getMessage();
    exit;
  } catch(FacebookExceptionsFacebookSDKException $e) {
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
    exit;
  }
  $graphNode = $response->getGraphNode();

    foreach ($graphNode['data'] as $post): ?>
      <section class="bg-primary">
        <div class="container">
          <div class="row">
            <div class="col-lg-8 mx-auto text-center">
              <h2 class="section-heading text-white">Verslag: <?php echo $post['created_time']; ?></h2>
              <hr class="light">
              <p class="text-faded"><<?php echo $post['message']; ?></p>
            </div>
          </div>
        </div>
      </section>
    <?php endforeach; ?>
Dries Jans
  • 107
  • 1
  • 11
  • You did remove the curly braces around the actual access token value, right …? – CBroe Feb 08 '18 at 16:01
  • Yes, now I've tried again and I get a other error message ( due to a cache issue I guess). It says it has something to do with my appsecret_proof. Message: Invalid appsecret_proof provided in the API argument. – Dries Jans Feb 08 '18 at 17:11
  • 2
    That means your app ID or app secret are wrong, or your access token is not from the correct app. If you got the token from the Graph API Explorer it's probably associated with the default Graph Explorer app, *not* your app. – ceejayoz Feb 08 '18 at 17:14

1 Answers1

0

It's like Ceejayoz says, my page and my app were not linked and that's why I got a invalid appsecret message. I also got some troubles with linking the page and my app, but this question got answered here.

Dries Jans
  • 107
  • 1
  • 11