Facebook Marketing API PHP SDK - “Filtering field delivery_info is invalid”

删除回忆录丶 提交于 2019-12-24 19:28:16

问题


I'm attempting to make a PHP-application that generates Facebook ad reports for a company, using the Facebook PHP Ads SDK. I'm following the Marketing API QuickStart that essentially generates code for you. I have all access I need to reach the company's ad account ID. (I'm not showing the token- and ID-variables, unless absolutely necessary. If so, tell me).

require __DIR__ . '/vendor/autoload.php';

use FacebookAds\Object\AdAccount;
use FacebookAds\Object\AdsInsights;
use FacebookAds\Api;
use FacebookAds\Logger\CurlLogger;

$access_token;
$ad_account_id;
$app_secret;
$app_id;

$api = Api::init($app_id, $app_secret, $access_token);
$api->setLogger(new CurlLogger());

$fields = array(
    'frequency',
    'actions:link_click',
    'call_to_action_clicks',
    'actions:tab_view',
);
$params = array(
    'level' => 'adset',
    'filtering' => array(array('field' => 'delivery_info','operator' => 'IN','value' => array('inactive','active','limited','archived','permanently_deleted','completed','recently_completed','not_delivering','not_published','rejected','recently_rejected','rejected','pending_review','scheduled'))),
    'breakdowns' => array('place_page_id'),
    'time_range' => array('since' => '2017-09-20','until' => '2017-10-20'),
);
echo json_encode((new AdAccount($ad_account_id))->getInsights(
    $fields,
    $params
)->getResponse()->getContent(), JSON_PRETTY_PRINT);

However, when running the code I get the error message:

Fatal error: Uncaught exception 'FacebookAds\Http\Exception\AuthorizationException' with message '(#100) Filtering field delivery_info is invalid.

I try switching around in $fields and $params with parameters found in the documentation, but it switches the blame on other ones as I do, even claiming that some of them don't even exist as alternatives. I've checked several times in the documentation, it should work.

Does the problem lie elsewhere, is it the wrong kind of ad account ID?

Any help would be very much appreciated.


回答1:


Try adset.delivery_info instead of just delivery_info. That should work. I learned the hard way, seems like you need to append the object level separated by period for filtering options.



来源:https://stackoverflow.com/questions/46824974/facebook-marketing-api-php-sdk-filtering-field-delivery-info-is-invalid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!