[英]Facebook Business SDK PHP - Cannot Fetch Campaign Fields
I am trying to get the campaign names of an ad account with the following code我正在尝试使用以下代码获取广告帐户的广告系列名称
$account = new AdAccount($account_id);
$cursor = $account->getCampaigns();
echo sizeof($cursor);
// Loop over objects
foreach ($cursor as $campaign) {
echo $campaign->{CampaignFields::NAME}.PHP_EOL;
}
The cursor has the correct number of campaigns but I get empty field values.光标具有正确数量的活动,但我得到空字段值。 Same applies when I try to get the Ad Account fields.当我尝试获取广告帐户字段时同样适用。
Does anybody know why is this happening?有人知道为什么会这样吗? I am using the latest version of API (v5.0)我使用的是最新版本的 API (v5.0)
Thanks in advance.提前致谢。
You should add the field you want to request by the API in the method, as example:您应该在方法中添加您要通过 API 请求的字段,例如:
$cursor = $account->getCampaigns(['id','name']);
Refer also to the AdAccountsCampaigns example for further details about the usage of fields
and params
:另请参阅AdAccountsCampaigns示例,了解有关fields
和params
用法的更多详细信息:
$fields = array(
'name',
'objective',
);
$params = array(
'effective_status' => array('ACTIVE','PAUSED'),
);
echo json_encode((new AdAccount($id))->getCampaigns(
$fields,
$params
)->getResponse()->getContent(), JSON_PRETTY_PRINT);
Hope this help希望这有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.