examples/AdWords/v201809/ShoppingCampaigns/AddShoppingCampaignForShowcaseAds.php
private static function createShowcaseAd(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        AdGroup $adGroup
    ) {
        // Create the Showcase ad.
        $adGroupAdService = $adWordsServices->get($session, AdGroupAdService::class);

        $showcaseAd = new ShowcaseAd();
        $showcaseAd->setName('Showcase ad #' . uniqid());
        $showcaseAd->setFinalUrls(['http://example.com/showcase']);
        $showcaseAd->setDisplayUrl('example.com');

        // Required: Set the ad's expanded image.
        $expandedImage = new Image();
        $expandedImage->setMediaId(
            self::uploadImage(
                $adWordsServices,
                $session,
                'https://goo.gl/IfVlpF'
            )
        );
        $showcaseAd->setExpandedImage($expandedImage);

        // Optional: Set the collapsed image.
        $collapsedImage = new Image();
        $collapsedImage->setMediaId(
            self::uploadImage(
                $adWordsServices,
                $session,
                'https://goo.gl/NqTxAE'
            )
        );
        $showcaseAd->setCollapsedImage($collapsedImage);

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

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

        // Creates an ad group ad on the server.
        $adGroupAdAddResult = $adGroupAdService->mutate([$adGroupAdOperation]);
        $adGroupAd = $adGroupAdAddResult->getValue()[0];

        return $adGroupAd;
    }
private static function createShowcaseAd(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        AdGroup $adGroup
    ) {
        // Create the Showcase ad.
        $adGroupAdService = $adWordsServices->get($session, AdGroupAdService::class);

        $showcaseAd = new ShowcaseAd();
        $showcaseAd->setName('Showcase ad #' . uniqid());
        $showcaseAd->setFinalUrls(['http://example.com/showcase']);
        $showcaseAd->setDisplayUrl('example.com');

        // Required: Set the ad's expanded image.
        $expandedImage = new Image();
        $expandedImage->setMediaId(
            self::uploadImage(
                $adWordsServices,
                $session,
                'https://goo.gl/IfVlpF'
            )
        );
        $showcaseAd->setExpandedImage($expandedImage);

        // Optional: Set the collapsed image.
        $collapsedImage = new Image();
        $collapsedImage->setMediaId(
            self::uploadImage(
                $adWordsServices,
                $session,
                'https://goo.gl/NqTxAE'
            )
        );
        $showcaseAd->setCollapsedImage($collapsedImage);

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

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

        // Creates an ad group ad on the server.
        $adGroupAdAddResult = $adGroupAdService->mutate([$adGroupAdOperation]);
        $adGroupAd = $adGroupAdAddResult->getValue()[0];

        return $adGroupAd;
    }
private static function createShowcaseAd ( AdWordsServices $ adWordsServices , AdWordsSession $ session , AdGroup $ adGroup ) { // Create the Showcase ad. $ adGroupAdService = $ adWordsServices -> get ( $ session , AdGroupAdService :: class ) ; $ showcaseAd = new ShowcaseAd ( ) ; $ showcaseAd -> setName ( 'Showcase ad #' . uniqid ( ) ) ; $ showcaseAd -> setFinalUrls ( [ 'http://example.com/showcase' ] ) ; $ showcaseAd -> setDisplayUrl ( 'example.com' ) ; // Required: Set the ad's expanded image. $ expandedImage = new Image ( ) ; $ expandedImage -> setMediaId ( self :: uploadImage ( $ adWordsServices , $ session , 'https://goo.gl/IfVlpF' ) ) ; $ showcaseAd -> setExpandedImage ( $ expandedImage ) ; // Optional: Set the collapsed image. $ collapsedImage = new Image ( ) ; $ collapsedImage -> setMediaId ( self :: uploadImage ( $ adWordsServices , $ session , 'https://goo.gl/NqTxAE' ) ) ; $ showcaseAd -> setCollapsedImage ( $ collapsedImage ) ; // Create ad group ad. $ adGroupAd = new AdGroupAd ( ) ; $ adGroupAd -> setAdGroupId ( $ adGroup -> getId ( ) ) ; $ adGroupAd -> setAd ( $ showcaseAd ) ; // Create an ad group ad operation. $ adGroupAdOperation = new AdGroupAdOperation ( ) ; $ adGroupAdOperation -> setOperand ( $ adGroupAd ) ; $ adGroupAdOperation -> setOperator ( Operator :: ADD ) ; // Creates an ad group ad on the server. $ adGroupAdAddResult = $ adGroupAdService -> mutate ( [ $ adGroupAdOperation ] ) ; $ adGroupAd = $ adGroupAdAddResult -> getValue ( ) [ 0 ] ; return $ adGroupAd ; }
Creates a Showcase ad.
Creates a Showcase ad .