获得“页面公共内容访问权”

时间:2019-09-01 19:25:37

标签: php facebook facebook-graph-api

响应:

图形返回错误:(#10)要使用“页面公共内容访问”,您对此端点的使用必须经过Facebook的审查和批准。要提交此“页面公共内容访问”功能以供审核,请阅读我们有关可审核功能的文档:https://developers.facebook.com/docs/apps/review

我的代码

    $token = "EABTiK*****841Xev8OFqRwt1NDReFbAW3yfZAe8esGNi9d5mQdVFrGpC8wDFbrWSeMseXeVybPuBTM72hEtN227guDLVlr99c8nAbmqZBEIjBApmvpWV5ua82aACX5cmmikK6WuZBIbiWs5yWAZB1wbQDTZAh89fh2EnzCKKzC0H2blcG8ZCxjTeloNZCZAVOhIVJVyztuarlpBL29Xp";
    $fb = new \Facebook\Facebook([
      'app_id' => '58*****897306',
      'app_secret' => '2a3*****e17bad2a70dd1e35',
      'default_graph_version' => 'v4.0',
     ]);


  try {
    // Get the \Facebook\GraphNodes\GraphUser object for the current user.
    // If you provided a 'default_access_token', the '{access-token}' is optional.
    $response = $fb->get('/me/accounts', $token);
    $sPageID = "175007559896929";
    $response = $fb->get('/' . $sPageID . '?fields=posts',$token);

  } catch(\Facebook\Exceptions\FacebookResponseException $e) {
    //When Graph returns an error
    echo 'Graph returned an error: ' . $e->getMessage();
    exit;
  } catch(\Facebook\Exceptions\FacebookSDKException $e) {
    // When validation fails or other local issues
    echo 'Facebook SDK returned an error: ' . $e->getMessage();
    exit;
  }

  $me = $response->getGraphUser();
  //echo 'Logged in as ' . $me->getName();
  print_r($me);

      try {

            $res = $fb->get('/me/accounts', $token);
            $res = $res->getDecodedBody();

            $id = "323395394774182";

            $res = $fb->get($id . '/feed', $token);

            $res = $res->getGraphEdge()->asArray();
            print_r($res);
        } catch( Facebook\Exceptions\FacebookSDKException $e ) {

                //echo $e->getMessage();
                exit;
        }

1 个答案:

答案 0 :(得分:0)

您正在尝试获取未管理页面的提要,或者您没有为其使用页面令牌。


$res = $fb->get('/me/accounts?fields=id,name,access_token', $token);