In getcampaigns <https://github.com/googleads/google-ads-php/blob/master/examples/BasicOperations/GetCampaigns.php> instead of using search stream im trying to use search. But I'm getting null values
namespace Google\Ads\GoogleAds\Examples\BasicOperations; require __DIR__ . '/../../vendor/autoload.php'; use GetOpt\GetOpt; use Google\Ads\GoogleAds\Examples\Utils\ArgumentNames; use Google\Ads\GoogleAds\Examples\Utils\ArgumentParser; use Google\Ads\GoogleAds\Lib\V3\GoogleAdsClient; use Google\Ads\GoogleAds\Lib\V3\GoogleAdsClientBuilder; use Google\Ads\GoogleAds\Lib\V3\GoogleAdsException; use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder; use Google\Ads\GoogleAds\Lib\V3\GoogleAdsServerStreamDecorator; use Google\Ads\GoogleAds\V3\Errors\GoogleAdsError; use Google\Ads\GoogleAds\V3\Services\GoogleAdsRow; use Google\Ads\GoogleAds\V3\Services\SearchGoogleAdsStreamResponse; use Google\Ads\GoogleAds\V3\Services\SearchGoogleAdsResponse; use Google\ApiCore\ApiException; /** This example gets all campaigns. To add campaigns, run AddCampaigns.php. */ class GetCampaigns { const CUSTOMER_ID = '**********'; public static function main() { $options = (new ArgumentParser())->parseCommandArguments([ ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT ]); // Generate a refreshable OAuth2 credential for authentication. // $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build(); // // Construct a Google Ads client configured from a properties file and the // // OAuth2 credentials above. // $googleAdsClient = (new GoogleAdsClientBuilder()) // ->fromFile() // ->withOAuth2Credential($oAuth2Credential) // ->build(); $oAuth2Credential = (new OAuth2TokenBuilder()) ->withClientId('*********-p4i6a80tjrm4kgp5akfs6bp00liq2601.apps.googleusercontent.com') ->withClientSecret("**********") ->withRefreshToken('***********************************************') ->build(); $googleAdsClient = (new GoogleAdsClientBuilder()) ->withOAuth2Credential($oAuth2Credential) ->withDeveloperToken('**************') ->withLoginCustomerId('**********') ->build(); try { self::runExample( $googleAdsClient, $options[ArgumentNames::CUSTOMER_ID] ?: self::CUSTOMER_ID ); } 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 ); } } catch (ApiException $apiException) { printf( "ApiException was thrown with message '%s'.%s", $apiException->getMessage(), PHP_EOL ); } } /** * Runs the example. * * @param GoogleAdsClient $googleAdsClient the Google Ads API client * @param int $customerId the customer ID */ 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. $stream =$googleAdsServiceClient->search($customerId, $query); $emptyarray=array(); foreach ($stream->iterateAllElements() as $googleAdsRow) { /** @var GoogleAdsRow $googleAdsRow */ array_push($emptyarray,$googleAdsRow->getAdGroup()->getId()->getValue()); printf( "Ad group with ID %d and name '%s' was found in campaign with ID .%s", $googleAdsRow->getCampaign()->getId()->getValue(), $googleAdsRow->getCampaign()->getName()->getValue(), PHP_EOL ); } echo count($emptyarray); } } GetCampaigns::main(); -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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 "AdWords API and Google Ads 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/af977548-7e4a-44dc-b0b3-94f916610829%40googlegroups.com.