0

我正在尝试了解我网站中 Facebook 页面上所有帖子的概述。但是我收到一条 Invalid appsecret_proof 提供的消息。当我在Graph API Explorer中尝试它时,一切正常,但是当我在我的测试场所尝试它时它不起作用。我想知道是否只是某种互联网连接问题,或者我的代码/令牌做错了什么。

<?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; ?>
4

1 回答 1

0

就像 Ceejayoz 说的,我的页面和我的应用程序没有链接,这就是我收到无效的 appsecret 消息的原因。我在链接页面和我的应用程序时也遇到了一些麻烦,但这个问题在这里得到了回答。

于 2018-02-09T10:37:28.823 回答