Facebook 营销 API 获取活动信息

Facebook Marketing API get campaign info

我正在使用 Facebook 自动生成的代码尝试连接到营销 API 以获取活动统计信息。这样做,我得到:

Uncaught FacebookAds\Http\Exception\AuthorizationException: (#100) results, actions:like, video_play_actions:video_view, video_avg_time_watched_actions:video_view, unique_actions:link_click are not valid for fields param.

$fields = array(
  'results',
  'reach',
  'actions:like',
  'video_play_actions:video_view',
  'video_avg_time_watched_actions:video_view',
  'unique_actions:link_click',
);
var_dump($fields);
$params = array(
  'level' => 'campaign',               
  'filtering' => array(array('field' => 'campaign.delivery_info','operator' => 'IN','value' => array('active'))),
  'breakdowns' => array(),
  'time_range' => array('since' => '2017-05-19','until' => '2019-05-19'),
);
echo json_encode((new AdAccount($ad_account_id))->getInsights(
  $fields,
  $params
)->getResponse()->getContent(), JSON_PRETTY_PRINT);

上面我用了 campaign.delivery_info 每个 this answer。我也尝试过(根据自动生成的代码):

'filtering' => array(array('field' => 'delivery_info','operator' => 'IN','value' => array('active')))

您似乎在要求旧值字段,试试这个:

$fields = array(
  'reach',
  'actions',
  'video_play_actions',
  'video_avg_time_watched_actions',
  'outbound_clicks',
);

希望对您有所帮助

注意:results 字段不可用