private static AdGroupAd createShowcaseAd ( AdWordsServicesInterface adWordsServices , AdWordsSession session , AdGroup adGroup ) throws IOException { // Create the Showcase ad. AdGroupAdServiceInterface adGroupAdService = adWordsServices . get ( session , AdGroupAdServiceInterface . class ) ; ShowcaseAd showcaseAd = new ShowcaseAd ( ) ; showcaseAd . setName ( "Showcase ad #" + System . currentTimeMillis ( ) ) ; showcaseAd . setFinalUrls ( new String [ ] { "http://example.com/showcase" } ) ; showcaseAd . setDisplayUrl ( "example.com" ) ; // Required: Set the ad's expanded image. Image expandedImage = new Image ( ) ; expandedImage . setMediaId ( uploadImage ( adWordsServices , session , "https://goo.gl/IfVlpF" ) ) ; showcaseAd . setExpandedImage ( expandedImage ) ; // Optional: Set the collapsed image. Image collapsedImage = new Image ( ) ; collapsedImage . setMediaId ( uploadImage ( adWordsServices , session , "https://goo.gl/NqTxAE" ) ) ; showcaseAd . setCollapsedImage ( collapsedImage ) ; // Create ad group ad. AdGroupAd adGroupAd = new AdGroupAd ( ) ; adGroupAd . setAdGroupId ( adGroup . getId ( ) ) ; adGroupAd . setAd ( showcaseAd ) ; // Create operation. AdGroupAdOperation adGroupAdOperation = new AdGroupAdOperation ( ) ; adGroupAdOperation . setOperand ( adGroupAd ) ; adGroupAdOperation . setOperator ( Operator . ADD ) ; // Make the mutate request. AdGroupAdReturnValue adGroupAdAddResult = adGroupAdService . mutate ( new AdGroupAdOperation [ ] { adGroupAdOperation } ) ; return adGroupAdAddResult . getValue ( 0 ) ; }
Creates a Showcase ad .