简体   繁体   English

Facebook 业务 SDK PHP - 无法获取活动字段

[英]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示例,了解有关fieldsparams用法的更多详细信息:

$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.

相关问题 如何通过使用Facebook-business-php-sdk调用Facebook市场API返回特定用户的所有Campaign信息 - How to return all Campaign information for a specific user by calling the Facebook market API using the Facebook-business-php-sdk Facebook Business PHP SDK:无法访问非拥有此应用程序的企业管理的对象 - Facebook Business PHP SDK : Cannot access an object not managed by the business owning this app Facebook PHP 业务 SDK 测试事件 - Facebook PHP Business SDK Test Event facebook PHP sdk无法登录 - facebook PHP sdk cannot login 无法使用 Facebook Business SDK 创建广告集 - Cannot create Ad Set using Facebook Business SDK 通过 Facebook PHP Business SDK 为广告上传视频状态 - Uploaded video status via Facebook PHP Business SDK for advertisements 使用最新的PHP SDK将Facebook发布到业务/社区页面 - Facebook post to business/community page using latest PHP SDK 如何在 facebook business sdk php 上创建产品目录批处理、电子商务 - how to create Product Catalog Batch , ecommerce on facebook business sdk php 如何访问自定义字段Facebook PHP SDK - How to access custom fields Facebook PHP SDK 尝试使用PHP SDK更新Bing Ads广告系列的CampaignCriterions时,无法创建抽象类错误 - Cannot create an abstract class error while trying to update CampaignCriterions for a Bing Ads Campaign using PHP SDK
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM