我正在尝试通过ID跟踪Google ADS广告系列的费用。 代码示例或教程都无济于事。
我只能通过此示例获取广告系列
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201809\cm\CampaignService;
use Google\AdsApi\AdWords\v201809\cm\OrderBy;
use Google\AdsApi\AdWords\v201809\cm\Paging;
use Google\AdsApi\AdWords\v201809\cm\Selector;
use Google\AdsApi\Common\OAuth2TokenBuilder;
$oAuth2Credential = (new OAuth2TokenBuilder())
->fromFile( __DIR__ .'/key/ads.ini')
->build();
$session = (new AdWordsSessionBuilder())
->fromFile( __DIR__ .'/key/ads.ini')
->withOAuth2Credential($oAuth2Credential)
->build();
$adWordsServices = new AdWordsServices();
$campaignService = $adWordsServices->get($session, CampaignService::class);
// Create selector.
$selector = new Selector();
$selector->setFields(array('Id', 'Name'));
$selector->setOrdering(array(new OrderBy('Name', 'ASCENDING')));
// Create paging controls.
$selector->setPaging(new Paging(0, 100));
// Make the get request.
$page = $campaignService->get($selector);
它工作正常。我无法设置其他字段(费用或预算),但会引发错误。