<?php
use Google\AdsApi\AdManager\Util\v202302\StatementBuilder;
use Illuminate\Support\Facades\Log;
$ini = parse_ini_file(resource_path('adsapi_php.ini'), true);
$ini['OAUTH2']['jsonKeyFilePath'] = resource_path($ini['OAUTH2']['jsonKeyFilePath']);
$configuration = new Configuration($ini);
$oAuth2Credential = (new OAuth2TokenBuilder())
->from($configuration)
->build();
// Construct an API session configured from an `adsapi_php.ini` file
// and the OAuth2 credentials above.
$this->session = (new AdManagerSessionBuilder())->from($configuration)
->withOAuth2Credential($oAuth2Credential)
->build();
$this->serviceFactory = new ServiceFactory();
$creativeService = $this->serviceFactory->createCreativeService($this->session);
$creativeService = $this->serviceFactory->createCreativeService($this->session);
$statementBuilder = (new StatementBuilder())->where('id = :id')
->limit(1)
->withBindVariableValue('id', CREATIVEIDHERE);
$page = $creativeService->getCreativesByStatement(
$statementBuilder->toStatement()
);
//this is producing the correct creative
Log::info(sprintf("Found %s Creatives with id %s", count($page->getResults()), $creative->provider_id));
$action = new ActivateCreatives();
$result = $creativeService->performCreativeAction(
$action,
$statementBuilder->toStatement();
);
Permissions for the service account are set to administrator. I can activate the line item and the order, but Creative will not activate/deactivate. Alternatively, if it's possible to enable/disable a creative another way, that would be great.
Hi @illusive-ch - This issue seems related to the Ad Manager API itself, not the client library. Please contact their support by emailing admanagerapi-support@google.com.
When activating or deactivating the creative I get the following error
Here is the code to replicate
Permissions for the service account are set to administrator. I can activate the line item and the order, but Creative will not activate/deactivate. Alternatively, if it's possible to enable/disable a creative another way, that would be great.