As a result of executing the code below, I do not receive any 
data. Although, for example, such an example as GetAccountHierarchy works 
for me. I am currently working on migrating a running project from adWords 
API to Ads API. Can it be not in the code, but in the account settings?

My PHP Class Code:

class CheckController extends AbstractController
{

public function index()
{
$config = $this->getParameter('kernel.project_dir') . '/google_ads_php.ini';

if (!is_file($config)) return $this->json([$config]);

$oAuth2Credential = (new OAuth2TokenBuilder())
->fromFile()
->build();
//dd($oAuth2Credential);
$googleAdsClient = (new GoogleAdsClientBuilder())
->fromFile()
->withOAuth2Credential($oAuth2Credential)
->build();

try {
self::runExample(
$googleAdsClient,
xxxxxxxxxx
);
} catch (GoogleAdsException $googleAdsException) {
printf(
"Request with ID '%s' has failed.%sGoogle Ads failure details:%s",
$googleAdsException->getRequestId(),
PHP_EOL,
PHP_EOL
);
foreach ($googleAdsException->getGoogleAdsFailure()->getErrors() as $error) 
{
/** @var GoogleAdsError $error */
printf(
"\t%s: %s%s",
$error->getErrorCode()->getErrorCode(),
$error->getMessage(),
PHP_EOL
);
}
exit(1);
} catch (ApiException $apiException) {
printf(
"ApiException was thrown with message '%s'.%s",
$apiException->getMessage(),
PHP_EOL
);
exit(1);
}
}

/**
* @param GoogleAdsClient $googleAdsClient
* @param int $customerId
* @return void
* @throws ApiException
*/
public static function runExample(GoogleAdsClient $googleAdsClient, int 
$customerId)
{
$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
// Creates a query that retrieves all campaigns.
$query = 'SELECT campaign.id, campaign.name FROM campaign ORDER BY 
campaign.id';
// Issues a search stream request.
/** @var GoogleAdsServerStreamDecorator $stream */
$stream =
$googleAdsServiceClient->searchStream($customerId, $query);

// Iterates over all rows in all messages and prints the requested field 
values for
// the campaign in each row.
foreach ($stream->iterateAllElements() as $googleAdsRow) {
/** @var GoogleAdsRow $googleAdsRow */
printf(
"Campaign with ID %d and name '%s' was found.%s",
$googleAdsRow->getCampaign()->getId(),
$googleAdsRow->getCampaign()->getName(),
PHP_EOL
);
}
}

public static function runListExample(GoogleAdsClient $googleAdsClient)
{
$customerServiceClient = $googleAdsClient->getCustomerServiceClient();

// Issues a request for listing all accessible customers.
$accessibleCustomers = $customerServiceClient->listAccessibleCustomers();
print 'Total results: ' . count($accessibleCustomers->getResourceNames()) . 
PHP_EOL;

// Iterates over all accessible customers' resource names and prints them.
foreach ($accessibleCustomers->getResourceNames() as $resourceName) {
/** @var string $resourceName */
printf("Customer resource name: '%s'%s", $resourceName, PHP_EOL);
}
}
}

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/d3f373d8-02bd-4a49-830f-0bb5674274f8n%40googlegroups.com.

Reply via email to