Facebook Marketing API PHP SDK - “过滤字段 delivery_info 无效" [英] Facebook Marketing API PHP SDK - "Filtering field delivery_info is invalid"

查看:89
本文介绍了Facebook Marketing API PHP SDK - “过滤字段 delivery_info 无效"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Facebook PHP Ads SDK 制作一个为公司生成 Facebook 广告报告的 PHP 应用程序.我正在关注营销 API 快速入门,它基本上为您生成代码.我拥有访问公司广告帐户 ID 所需的所有访问权限.(除非绝对必要,否则我不会显示令牌和 ID 变量.如果是,请告诉我).

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:

致命错误:未捕获的异常带有消息的FacebookAds\Http\Exception\AuthorizationException"'(#100) 过滤字段 delivery_info 无效.

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

我尝试使用文档中找到的参数在 $fields$params 中切换,但它像我一样将责任转移到其他人身上,甚至声称有些其中甚至不作为替代品存在.我已经在文档中检查了几次,它应该可以工作.

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.

问题是否出在其他地方,是不是广告帐户 ID 类型错误?

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

非常感谢任何帮助.

推荐答案

尝试 adset.delivery_info 而不是 delivery_info.那应该工作.我学到了艰难的方法,似乎您需要附加以句点分隔的对象级别以进行过滤选项.

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.

这篇关于Facebook Marketing API PHP SDK - “过滤字段 delivery_info 无效"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆