Hi Josh, 

We are trying to upload HTML5 Ad Template for Dynamic Remarketing for 
Retail. But, it is now showing the preview properly as compared to manual 
upload of zip file. Can you please help us trouble shoot? 

<?php
/**
 * Copyright 2017 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
namespace Google\AdsApi\Examples\AdWords\v201806\ShoppingCampaigns;
require 'googleads-php-lib-master/vendor/autoload.php';
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201806\cm\AdGroupAd;
use Google\AdsApi\AdWords\v201806\cm\AdGroupAdOperation;
use Google\AdsApi\AdWords\v201806\cm\AdGroupAdService;
use Google\AdsApi\AdWords\v201806\cm\AdGroupAdStatus;
use Google\AdsApi\AdWords\v201806\cm\Dimensions;
use Google\AdsApi\AdWords\v201806\cm\MediaBundle;
use Google\AdsApi\AdWords\v201806\cm\Operator;
use Google\AdsApi\AdWords\v201806\cm\TemplateAd;
use Google\AdsApi\AdWords\v201806\cm\TemplateElement;
use Google\AdsApi\AdWords\v201806\cm\TemplateElementField;
use Google\AdsApi\AdWords\v201806\cm\TemplateElementFieldType;
use Google\AdsApi\AdWords\v201806\cm\MediaService;
use Google\AdsApi\AdWords\v201806\cm\MediaMediaType;
use Google\AdsApi\Common\MapEntries;
use Google\AdsApi\Common\OAuth2TokenBuilder;
/**
 * This example adds an HTML5 ad to given ad group. To get ad groups, run
 * GetAdGroups.php.
 */
class AddHtml5Ad{
    //const AD_GROUP_ID = '60612836284';
    const AD_GROUP_ID = '58679041196';
    public static function runExample(AdWordsServices 
$adWordsServices,AdWordsSession $session,$adGroupId) {
        try{   
            $adGroupAdService = $adWordsServices->get($session, 
AdGroupAdService::class);
            $operations = [];
            // Create a template ad.
            $html5Ad = new TemplateAd();
            $html5Ad->setName('html5');
            // 419 represents uplofadsaded HTML5 bundle. See
            // 
https://developers.google.com/adwords/api/docs/appendix/templateads
            // for details.
            $html5Ad->setTemplateId(419);
            
$html5Ad->setFinalUrls(['https://harry-potter-004.myshopify.com']);
            $html5Ad->setDisplayUrl('harry-potter-004.myshopify.com');

            $dimensions = new Dimensions();
            $dimensions->setWidth(160);
            $dimensions->setHeight(600);
            $html5Ad->setDimensions($dimensions);

            // The HTML5 zip file contains all the HTML, CSS, and images 
needed for the
            // HTML5 ad. For help on creating an HTML5 zip file, check out 
Google Web
            // Designer (https://www.google.com/webdesigner/).
            //$html5Zip = file_get_contents('https://goo.gl/9Y7qI2');
           // $html5Zip = 
file_get_contents('http://localhost/google_adword_app/ad/test/300/300.zip');
            $html5Zip = file_get_contents('new/160_600.zip'); 
            
            $mediaBundle = new MediaBundle();
            $mediaBundle->setData($html5Zip);
            //$mediaBundle->setEntryPoint('carousel/index.html');
            $mediaBundle->setType('MEDIA_BUNDLE');


            // Create the template elements for the ad. You can refer to
            // 
https://developers.google.com/adwords/api/docs/appendix/templateads
            // for the list of avaliable template fields.
            $media = new TemplateElementField();
            $media->setName('Custom_layout');
            $media->setFieldMedia($mediaBundle);
            $media->setType(TemplateElementFieldType::MEDIA_BUNDLE);

            $layout = new TemplateElementField();
            $layout->setName('layout');
            $layout->setFieldText('Custom');
            $layout->setType(TemplateElementFieldType::ENUM);

            $adData = new TemplateElement();
            $adData->setUniqueName('adData');
            $adData->setFields([$media, $layout]);

            $html5Ad->setTemplateElements([$adData]);

            // Create ad group ad.
            $adGroupAd = new AdGroupAd();
            $adGroupAd->setAdGroupId($adGroupId);
            $adGroupAd->setAd($html5Ad);
            // Optional: Set additional settings.
            //$adGroupAd->getAd()->setAdType("DYNAMIC_SEARCH_AD");
            $adGroupAd->getAd()->setAdType("THIRD_PARTY_REDIRECT_AD");
            $adGroupAd->setStatus(AdGroupAdStatus::ENABLED);

            // Create ad group ad operation and add it to the list.
            $operation = new AdGroupAdOperation();
            $operation->setOperand($adGroupAd);
            $operation->setOperator(Operator::ADD);
            $operations[] = $operation;

            // Create the ad group ad on the server and print out some 
information
            // about it.
            $result = $adGroupAdService->mutate($operations);
            foreach ($result->getValue() as $adGroupAd) {
                printf(
                    "New HTML5 ad with ID %d and display URL '%s' was 
created.\n",
                    $adGroupAd->getAd()->getId(),
                    $adGroupAd->getAd()->getDisplayUrl()
                );
            }
        }
        catch(\Exception $e){
            $msg=$e->getErrors()[0]->getReason();
            print_r($msg);
        }
    }
    public static function main(){
        // Generate a refreshable OAuth2 credential for authentication.
        $oAuth2Credential = (new OAuth2TokenBuilder())
        ->withClientId("ClientIdapp")
        ->withClientSecret("ClientSecret")
        ->withRefreshToken("refreshtoken")
        ->build();
        
        $session = (new AdWordsSessionBuilder())
        ->fromFile('adsapi_php.ini')
        ->withOAuth2Credential($oAuth2Credential)
        ->withClientCustomerId("")
        ->build();
        self::runExample(new 
AdWordsServices(),$session,intval(self::AD_GROUP_ID));
    }
}
AddHtml5Ad::main();

On Tuesday, 19 June 2018 23:34:33 UTC+5:30, Josh Radcliff (AdWords API 
Team) wrote:
>
> Hi,
>
> Although the AdWords API does not support template ID 416, you can now 
> create a ResponsiveDisplayAd 
> <https://developers.google.com/adwords/api/docs/reference/v201806/AdGroupAdService.ResponsiveDisplayAd>
>  for 
> your dynamic remarketing campaigns. The process for doing so will be 
> essentially the same as the *createAd* step of the Add a Shopping dynamic 
> remarketing campaign example 
> <https://developers.google.com/adwords/api/docs/samples/java/advanced-operations#add-a-shopping-dynamic-remarketing-campaign>
> .
>
> Thanks,
> Josh, AdWords API Team
>
> On Monday, June 18, 2018 at 4:19:40 PM UTC-4, Amit P Jivani wrote:
>>
>> Is this feature available now? 
>>
>>
>> On Saturday, 19 December 2015 01:52:56 UTC+5:30, Josh Radcliff (AdWords 
>> API Team) wrote:
>>>
>>> Hi,
>>>
>>> The AdWords API lets you manage the feed items for dynamic remarketing 
>>> ads, but it does not support creating the dynamic display ads (with 
>>> Template Ad ID 416) themselves. Therefore, you'll need to create the ads 
>>> through the user interface first. After that, you'll be able to use the API 
>>> to add/remove/update the dynamic data used for those ads.
>>>
>>> For more info on managing your feed items for dynamic remarketing ads, 
>>> check out our Dynamic Remarketing guide 
>>> <https://developers.google.com/adwords/api/docs/guides/dynamic-remarketing>
>>> .
>>>
>>> Thanks,
>>> Josh, AdWords API Team
>>>
>>> On Thursday, December 17, 2015 at 5:21:48 PM UTC-5, Ezequiel Murillo 
>>> wrote:
>>>>
>>>> Sorry, I think I didn't explain myself as I should have. I want to 
>>>> create an ad for a Dynamic Remarketing Campaign in the Display Network, 
>>>> not 
>>>> a Shopping campaign.
>>>> I would also like to have a many products in a single ad, so that's 
>>>> what I thought I would need a Template ad, I guess an html5 template ad. 
>>>> The type of ad I want to create using the API is like the one explained 
>>>> here:
>>>>
>>>> https://support.google.com/adwords/answer/3265299?hl=en
>>>>
>>>> When I create them using the UI I just choose a template and the images 
>>>> and everything are pulled from my Merchant Center. I'm just not sure how 
>>>> to 
>>>> do that from the API. 
>>>> I dont find the one in:
>>>> https://developers.google.com/adwords/api/docs/guides/template-ads
>>>> very informative.
>>>>
>>>> Thanks!
>>>>
>>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/28f76990-1075-4d2f-9219-8c6f4f937f5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • ... Amit P Jivani
    • ... 'Josh Radcliff (AdWords API Team)' via AdWords API and Google Ads API Forum
      • ... Amit P Jivani
        • ... 'Josh Radcliff (AdWords API Team)' via AdWords API and Google Ads API Forum
          • ... Amit P Jivani

Reply via email to