| public static function runExample(GoogleAdsClient $googleAdsClient, $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 request by specifying page size. |
| $response = |
| $googleAdsServiceClient->search($customerId, $query, ['pageSize' => self::PAGE_SIZE]); |
| |
| // Iterates over all rows in all pages and prints the requested field values for |
| // the campaign in each row. |
| foreach ($response->iterateAllElements() as $googleAdsRow) { |
| /** @var GoogleAdsRow $googleAdsRow */ |
| printf( |
| "Campaign with ID %d and name '%s' was found.%s", |
| $googleAdsRow->getCampaign()->getId()->getValue(), |
| $googleAdsRow->getCampaign()->getName()->getValue(), |
| PHP_EOL |
| ); |
| } |