examples/AdWords/v201809/AdvancedOperations/AddDynamicSearchAdsCampaign.php
private static function createAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        Campaign $campaign
    ) {
        $adGroupService = $adWordsServices->get($session, AdGroupService::class);

        // Create the ad group.
        $adGroup = new AdGroup();

        // Required: Set the ad group's type to Dynamic Search Ads.
        $adGroup->setAdGroupType(AdGroupType::SEARCH_DYNAMIC_ADS);

        $adGroup->setName('Interplanetary Cruise #' . uniqid());
        $adGroup->setCampaignId($campaign->getId());
        $adGroup->setStatus(AdGroupStatus::PAUSED);

        // Recommended: Set a tracking URL template for your ad group if you want to
        // use URL tracking software.
        $adGroup->setTrackingUrlTemplate(
            'http://tracker.example.com/traveltracker/{escapedlpurl}'
        );

        // Set the ad group bids.
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();

        $cpcBid = new CpcBid();
        $money = new Money();
        $money->setMicroAmount(3000000);
        $cpcBid->setBid($money);
        $biddingStrategyConfiguration->setBids([$cpcBid]);

        $adGroup->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

        // Create an ad group operation.
        $operation = new AdGroupOperation();
        $operation->setOperand($adGroup);
        $operation->setOperator(Operator::ADD);

        // Create the ad group on the server and print out some information.
        $result = $adGroupService->mutate([$operation]);
        $adGroup = $result->getValue()[0];
        printf(
            "Ad group with name '%s' and ID %d was added.\n",
            $adGroup->getName(),
            $adGroup->getId()
        );

        return $adGroup;
    }
private static function createAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        Campaign $campaign
    ) {
        $adGroupService = $adWordsServices->get($session, AdGroupService::class);

        // Create the ad group.
        $adGroup = new AdGroup();

        // Required: Set the ad group's type to Dynamic Search Ads.
        $adGroup->setAdGroupType(AdGroupType::SEARCH_DYNAMIC_ADS);

        $adGroup->setName('Interplanetary Cruise #' . uniqid());
        $adGroup->setCampaignId($campaign->getId());
        $adGroup->setStatus(AdGroupStatus::PAUSED);

        // Recommended: Set a tracking URL template for your ad group if you want to
        // use URL tracking software.
        $adGroup->setTrackingUrlTemplate(
            'http://tracker.example.com/traveltracker/{escapedlpurl}'
        );

        // Set the ad group bids.
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();

        $cpcBid = new CpcBid();
        $money = new Money();
        $money->setMicroAmount(3000000);
        $cpcBid->setBid($money);
        $biddingStrategyConfiguration->setBids([$cpcBid]);

        $adGroup->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

        // Create an ad group operation.
        $operation = new AdGroupOperation();
        $operation->setOperand($adGroup);
        $operation->setOperator(Operator::ADD);

        // Create the ad group on the server and print out some information.
        $result = $adGroupService->mutate([$operation]);
        $adGroup = $result->getValue()[0];
        printf(
            "Ad group with name '%s' and ID %d was added.\n",
            $adGroup->getName(),
            $adGroup->getId()
        );

        return $adGroup;
    }
private static function createAdGroup ( AdWordsServices $ adWordsServices , AdWordsSession $ session , Campaign $ campaign ) { $ adGroupService = $ adWordsServices -> get ( $ session , AdGroupService :: class ) ; // Create the ad group. $ adGroup = new AdGroup ( ) ; // Required: Set the ad group's type to Dynamic Search Ads. $ adGroup -> setAdGroupType ( AdGroupType :: SEARCH_DYNAMIC_ADS ) ; $ adGroup -> setName ( 'Interplanetary Cruise #' . uniqid ( ) ) ; $ adGroup -> setCampaignId ( $ campaign -> getId ( ) ) ; $ adGroup -> setStatus ( AdGroupStatus :: PAUSED ) ; // Recommended: Set a tracking URL template for your ad group if you want to // use URL tracking software. $ adGroup -> setTrackingUrlTemplate ( 'http://tracker.example.com/traveltracker/{escapedlpurl}' ) ; // Set the ad group bids. $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ cpcBid = new CpcBid ( ) ; $ money = new Money ( ) ; $ money -> setMicroAmount ( 3000000 ) ; $ cpcBid -> setBid ( $ money ) ; $ biddingStrategyConfiguration -> setBids ( [ $ cpcBid ] ) ; $ adGroup -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; // Create an ad group operation. $ operation = new AdGroupOperation ( ) ; $ operation -> setOperand ( $ adGroup ) ; $ operation -> setOperator ( Operator :: ADD ) ; // Create the ad group on the server and print out some information. $ result = $ adGroupService -> mutate ( [ $ operation ] ) ; $ adGroup = $ result -> getValue ( ) [ 0 ] ; printf ( "Ad group with name '%s' and ID %d was added.\n" , $ adGroup -> getName ( ) , $ adGroup -> getId ( ) ) ; return $ adGroup ; }
Creates the ad group.
Creates the ad group .