我正在尝试使用Facebook api从与我们的业务帐户相关联的广告帐户中检索广告系列,当我完成这一部分后,我想从广告系列中检索广告组(但这是另一回事)
<?php
require __DIR__ . '/vendor/autoload.php';
use FacebookAds\Api;
use FacebookAds\Logger\CurlLogger;
use FacebookAds\Object\AdAccount;
use FacebookAds\Object\Business;
$access_token = '';
$app_secret = '';
$app_id = '';
$businessId = '';
$api = Api::init($app_id, $app_secret, $access_token);
$api->setLogger(new CurlLogger());
$fields = array(
'name',
'objective',
);
$params = array(
'effective_status' => array('ACTIVE','PAUSED'),
);
$ownedAccounts = (new Business($businessId))->getOwnedAdAccounts($fields, $params)->getResponse()->getContent();
foreach ($ownedAccounts['data'] as $ownedAccount) {
$hmm = new AdAccount($ownedAccount['id']);
try {
$hmm->getCampaigns();
echo "Ok for : ". $ownedAccount['name'] . "\n";
} catch (Exception $e) {
echo "Failed for : ". $ownedAccount['name'] . "\n";
echo $e->getMessage() . "\n";
}
}
问题是我不断收到(#200)权限错误。
答案 0 :(得分:0)
该应用的系统用户无权访问广告帐户,将其添加到系统用户即可解决该问题