Php Facebook API-不支持获取页面/帖子洞察请求

Php Facebook API-不支持获取页面/帖子洞察请求,php,facebook,facebook-graph-api,Php,Facebook,Facebook Graph Api,我知道关于Facebook的SDK和API以及这个特定的错误响应有很多问题,但是他们似乎都没有回答我的问题 我运行了一个Facebook页面,直到几天前,我还运行了一些代码,可以收集我Facebook页面上每篇帖子的insights数据 这就是我所做的: define('FB_APP_ACCESS_TOKEN', 'omitted'); // Never expires, has permission to read insight data (and more) define('FB_APP_

我知道关于Facebook的SDK和API以及这个特定的错误响应有很多问题,但是他们似乎都没有回答我的问题

我运行了一个Facebook页面,直到几天前,我还运行了一些代码,可以收集我Facebook页面上每篇帖子的
insights
数据

这就是我所做的:

define('FB_APP_ACCESS_TOKEN', 'omitted'); // Never expires, has permission to read insight data (and more)
define('FB_APP_ID', 'omitted'); // ID of my Facebook App
define('FB_APP_SECRET', 'omitted'); // Secret for App
define('FB_ACCOUNT_ID', 'omitted'); // Facebook ID of my page
define('FB_REQUEST', 'insights/post_impressions_unique,post_consumptions_by_type,post_negative_feedback_by_type,post_consumptions,post_story_adds_by_action_type');

// .. Require Facebook SDK (Using composer)
// .. Other processing


// Initialise the Facebook SDK with our credentials and permanent access token.
$fb = new Facebook\Facebook([
    'app_id' => FB_APP_ID,
    'app_secret' => FB_APP_SECRET,
    'default_graph_version' => 'v2.2'
]);
$fb->setDefaultAccessToken(FB_APP_ACCESS_TOKEN);


// .. Grab some posts from my database
foreach ($posts as $post) {
    $postId = $post['id'];
    $request = FB_ACCOUNT_ID . '_' . $postId . '/' . FB_REQUEST;
    // Request will now contain something like...
    // <PAGE_ID>_<POST_ID>/insights/post_impressions_unique,post_consumptions_by_type,post_negative_feedback_by_type,post_consumptions,post_story_adds_by_action_type

    try {
        $fb->get($response); // This line fails and throw exception

        // .. Rest of my processing
    } catch (Facebook\Exceptions\FacebookSDKException $e) {
        die("\nEXCEPTION: {$e->getMessage()}\n{$e->getTraceAsString()}");
    }
}
无论我做了什么尝试,我似乎都无法在一个页面上获得一篇文章的见解。我尝试过使用Graph API Explorer,尝试了许多组合,但似乎没有得到任何回报。我甚至尝试用正确的权限生成新的令牌,但都没有用。我尝试过的一些组合:

  • /insights
    -
    (#12)对于v2.4及更高版本,不推荐使用singular statuses API
  • /insights
    -显示页面的所有细节,不显示任何特定帖子
有人知道我哪里出错了吗


干杯

除了在每个请求中始终具有正确的访问令牌之外,位于

包含一个提示:

/{post id}/insights(仅限页面帖子)* *注意:图形API对象{post id}需要以API调用返回的相同格式指定,以获取页面帖子列表-不要尝试拆分或组合其他id以形成帖子id

基线:尽量只使用

$request = $postId . '/' . FB_REQUEST;
而不是

$request = FB_ACCOUNT_ID . '_' . $postId . '/' . FB_REQUEST;

是的,我知道,但我总是确保我包括它。我已经通过SDK将其包括在内,并且我已经确保将其包括在Graph API Explorer tooThanks中,以获得您的答案。我试过你的建议,在我问题的第一个要点中提到了这一点。根据v2.5文档,当我尝试
/insights
时,我得到一个带有消息
(#12)的
OAutheException
,对于v2.4版和更高版本的
singular statuses API是不推荐的。我怎么知道
对应于
$postId
。这不在代码中。我尝试了我的一个页面的帖子,但没有返回错误消息。这很奇怪。我甚至尝试在Graph API Explorer中运行
/posts
,单击随机的post ID(显示该post的详细信息),然后简单地将
/insights
附加到请求中。然而,这显示了一个不同的错误:
发生了一个未知错误。
这正是我所做的。你在使用v2.5吗?acces令牌是否包含
read\u insights
权限?
$request = FB_ACCOUNT_ID . '_' . $postId . '/' . FB_REQUEST;