examples/AdWords/v201809/AdvancedOperations/AddDynamicSearchAdsCampaign.php
private static function createExpandedDSA(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        AdGroup $adGroup
    ) {
        $adGroupAdService = $adWordsServices->get($session, AdGroupAdService::class);

        // Create the expanded Dynamic Search Ad. This ad will have its headline
        // and final URL auto-generated at serving time according to domain name
        // specific information provided by DynamicSearchAdsSetting at the
        // campaign level.
        $expandedDSA = new ExpandedDynamicSearchAd();
        // Set the ad description.
        $expandedDSA->setDescription('Buy your tickets now!');
        $expandedDSA->setDescription2('Discount ends soon');

        // Create the ad group ad.
        $adGroupAd = new AdGroupAd();
        $adGroupAd->setAdGroupId($adGroup->getId());
        $adGroupAd->setAd($expandedDSA);

        // Optional: Set the status.
        $adGroupAd->setStatus(AdGroupAdStatus::PAUSED);

        // Create the operation.
        $operation = new AdGroupAdOperation();
        $operation->setOperator(Operator::ADD);
        $operation->setOperand($adGroupAd);

        // Create the ad on the server and print some information.
        $result = $adGroupAdService->mutate([$operation]);
        $newAdGroupAd = $result->getValue()[0];
        $expandedDSA = $newAdGroupAd->getAd();
        printf(
            "Expanded Dynamic Search Ad with ID %d, description '%s', and"
            . " description 2 '%s' was added.%s",
            $expandedDSA->getId(),
            $expandedDSA->getDescription(),
            $expandedDSA->getDescription2(),
            PHP_EOL
        );
    }
private static function createExpandedDSA(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        AdGroup $adGroup
    ) {
        $adGroupAdService = $adWordsServices->get($session, AdGroupAdService::class);

        // Create the expanded Dynamic Search Ad. This ad will have its headline
        // and final URL auto-generated at serving time according to domain name
        // specific information provided by DynamicSearchAdsSetting at the
        // campaign level.
        $expandedDSA = new ExpandedDynamicSearchAd();
        // Set the ad description.
        $expandedDSA->setDescription('Buy your tickets now!');
        $expandedDSA->setDescription2('Discount ends soon');

        // Create the ad group ad.
        $adGroupAd = new AdGroupAd();
        $adGroupAd->setAdGroupId($adGroup->getId());
        $adGroupAd->setAd($expandedDSA);

        // Optional: Set the status.
        $adGroupAd->setStatus(AdGroupAdStatus::PAUSED);

        // Create the operation.
        $operation = new AdGroupAdOperation();
        $operation->setOperator(Operator::ADD);
        $operation->setOperand($adGroupAd);

        // Create the ad on the server and print some information.
        $result = $adGroupAdService->mutate([$operation]);
        $newAdGroupAd = $result->getValue()[0];
        $expandedDSA = $newAdGroupAd->getAd();
        printf(
            "Expanded Dynamic Search Ad with ID %d, description '%s', and"
            . " description 2 '%s' was added.%s",
            $expandedDSA->getId(),
            $expandedDSA->getDescription(),
            $expandedDSA->getDescription2(),
            PHP_EOL
        );
    }
private static function createExpandedDSA ( AdWordsServices $ adWordsServices , AdWordsSession $ session , AdGroup $ adGroup ) { $ adGroupAdService = $ adWordsServices -> get ( $ session , AdGroupAdService :: class ) ; // Create the expanded Dynamic Search Ad. This ad will have its headline // and final URL auto-generated at serving time according to domain name // specific information provided by DynamicSearchAdsSetting at the // campaign level. $ expandedDSA = new ExpandedDynamicSearchAd ( ) ; // Set the ad description. $ expandedDSA -> setDescription ( 'Buy your tickets now!' ) ; $ expandedDSA -> setDescription2 ( 'Discount ends soon' ) ; // Create the ad group ad. $ adGroupAd = new AdGroupAd ( ) ; $ adGroupAd -> setAdGroupId ( $ adGroup -> getId ( ) ) ; $ adGroupAd -> setAd ( $ expandedDSA ) ; // Optional: Set the status. $ adGroupAd -> setStatus ( AdGroupAdStatus :: PAUSED ) ; // Create the operation. $ operation = new AdGroupAdOperation ( ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operation -> setOperand ( $ adGroupAd ) ; // Create the ad on the server and print some information. $ result = $ adGroupAdService -> mutate ( [ $ operation ] ) ; $ newAdGroupAd = $ result -> getValue ( ) [ 0 ] ; $ expandedDSA = $ newAdGroupAd -> getAd ( ) ; printf ( "Expanded Dynamic Search Ad with ID %d, description '%s', and" . " description 2 '%s' was added.%s" , $ expandedDSA -> getId ( ) , $ expandedDSA -> getDescription ( ) , $ expandedDSA -> getDescription2 ( ) , PHP_EOL ) ; }
Creates the expanded Dynamic Search Ad.
Creates the expanded Dynamic Search Ad .