Re: Unable to use Template Ads to create video ads with youtube url

2018-01-10 Thread 'Bharani Cherukuri (AdWords API Team)' via AdWords API Forum
Hello, 

The OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE 

 error 
is noticed when the operation is not permitted on the campaign type 
(DISPLAY). The TrueView in-search video template ads 

 with 
template ID: 231 will no longer accept new ads for that template, for 
display network campaigns. You may refer to this blog post 

 for 
more information. 

Regards,
Bharani, AdWords API Team

On Wednesday, January 10, 2018 at 4:07:09 AM UTC-5, Bruce Chiu wrote:
>
>
> Hi 
>
> I tried to use template ads create a video template ad service. 
> I referred the document,  but has some error message.
>
> my code:
>
> $adGroupAdService = $adWordsServices->get($session, AdGroupAdService::
> class);
> $operations = [];
> // Create a template ad.
> $youtubeAd = new TemplateAd();
> $youtubeAd->setName('TestAd');
>
> $youtubeAd->setTemplateId(*231*);
> $youtubeAd->setFinalUrls(['https://www.google.com']);
> $youtubeAd->setDisplayUrl('www.google.com');
>
> $headline = new TemplateElementField();
> $headline->setName('headline');
> $headline->setType(TemplateElementFieldType::TEXT);
> $headline->setFieldText('Enjoy');
>
> $videoId = new TemplateElementField();
> $videoId->setName('videoId');
> $videoId->setType(TemplateElementFieldType::VIDEO);
> $videoId->setFieldText('https://youtu.be/m6S4phxKEM8');
>
> $channel = new TemplateElementField();
> $channel->setName('channelName');
> $channel->setType(TemplateElementFieldType::TEXT);
> $channel->setFieldText('youtube.com/Google');
>
> $image = new TemplateElementField();
> $image->setName('imageUrl');
> $image->setType(TemplateElementFieldType::URL);
> $image->setFieldText('');
>
> $adData = new TemplateElement();
> $adData->setUniqueName('adData');
> $adData->setFields([$headline, $videoId, $channel, $image]);
>
> $youtubeAd->setTemplateElements([$adData]);
>
> // Create ad group ad.
> $adGroupAd = new AdGroupAd();
> $adGroupAd->setAdGroupId($adGroupId);
> $adGroupAd->setAd($youtubeAd);
> // Optional: Set additional settings.
> $adGroupAd->setStatus(AdGroupAdStatus::PAUSED);
>
>
> // 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()
>   );
> }
>
> error msg:
>
> Fatal error: Uncaught Google\AdsApi\AdWords\v201710\cm\ApiException: [
> AdError.INVALID_YOUTUBE_DISPLAY_URL @ operations[0].operand.ad.displayUrl, 
> OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ 
> operations[0].operand.ad; trigger:'DISPLAY', AdError.EMPTY_FIELD @ 
> operations[0].operand.ad.templateElements[0].fields[1].fieldMedia; trigger
> :'', AdError.EMPTY_FIELD @ operations[0].operand.ad.templateElements
> [0].fields[3].fieldText; trigger:'', UrlError.INVALID_FINAL_URL @ 
> operations[0].operand.ad.finalUrls[0]; trigger:'https://www.google.com']
>
> How should I fix it?
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 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/a379cd64-5552-4646-b094-9f56189b4e64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


unable to use template ads to create video ads with youtube url

2018-01-10 Thread Bruce Chiu
Hi 

i was trying to create a template ad with youtube url.
use templateId : 231  and give all required parameters. 
but have some errors. Is there anything wrong?

my code:

$adGroupAdService = $adWordsServices->get($session, AdGroupAdService::
class);
$operations = [];
// Create a template ad.
$youtubeAd = new TemplateAd();
$youtubeAd->setName('TestAd for youtube');

$youtubeAd->setTemplateId(231);
$youtubeAd->setFinalUrls(['https://www.google.com']);
$youtubeAd->setDisplayUrl('www.google.com');

$headline = new TemplateElementField();
$headline->setName('headline');
$headline->setType(TemplateElementFieldType::TEXT);
$headline->setFieldText('Enjoy');

$videoId = new TemplateElementField();
$videoId->setName('videoId');
$videoId->setType(TemplateElementFieldType::VIDEO);
$videoId->setFieldText('https://youtu.be/m6S4phxKEM8');

$channel = new TemplateElementField();
$channel->setName('channelName');
$channel->setType(TemplateElementFieldType::TEXT);
$channel->setFieldText('youtube.com/Google');

$image = new TemplateElementField();
$image->setName('imageUrl');
$image->setType(TemplateElementFieldType::URL);
$image->setFieldText('');

$adData = new TemplateElement();
$adData->setUniqueName('adData');
$adData->setFields([$headline, $videoId, $channel, $image]);

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

// Create ad group ad.
$adGroupAd = new AdGroupAd();
$adGroupAd->setAdGroupId($adGroupId);
$adGroupAd->setAd($youtubeAd);
// Optional: Set additional settings.
$adGroupAd->setStatus(AdGroupAdStatus::PAUSED);

// 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()
  );
}

errors:
Fatal error: Uncaught Google\AdsApi\AdWords\v201710\cm\ApiException: [
AdError.INVALID_YOUTUBE_DISPLAY_URL @ operations[0].operand.ad.displayUrl, 
OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ operations
[0].operand.ad; trigger:'DISPLAY', AdError.EMPTY_FIELD @ operations[0].
operand.ad.templateElements[0].fields[1].fieldMedia; trigger:'', 
AdError.EMPTY_FIELD @ operations[0].operand.ad.templateElements[0].fields[3
].fieldText; trigger:'', UrlError.INVALID_FINAL_URL @ operations[0].
operand.ad.finalUrls[0]; trigger:'https://www.google.com']


-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 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/52d9fd15-ebe7-4c3c-8bba-2907ed0388ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Unable to use Template Ads to create video ads with youtube url

2018-01-10 Thread BruceChiu

Hi 

I tried to use template ads create a video template ad service. 
I referred the document,  but has some error message.

my code:

$adGroupAdService = $adWordsServices->get($session, AdGroupAdService::
class);
$operations = [];
// Create a template ad.
$youtubeAd = new TemplateAd();
$youtubeAd->setName('TestAd');

$youtubeAd->setTemplateId(*231*);
$youtubeAd->setFinalUrls(['https://www.google.com']);
$youtubeAd->setDisplayUrl('www.google.com');

$headline = new TemplateElementField();
$headline->setName('headline');
$headline->setType(TemplateElementFieldType::TEXT);
$headline->setFieldText('Enjoy');

$videoId = new TemplateElementField();
$videoId->setName('videoId');
$videoId->setType(TemplateElementFieldType::VIDEO);
$videoId->setFieldText('https://youtu.be/m6S4phxKEM8');

$channel = new TemplateElementField();
$channel->setName('channelName');
$channel->setType(TemplateElementFieldType::TEXT);
$channel->setFieldText('youtube.com/Google');

$image = new TemplateElementField();
$image->setName('imageUrl');
$image->setType(TemplateElementFieldType::URL);
$image->setFieldText('');

$adData = new TemplateElement();
$adData->setUniqueName('adData');
$adData->setFields([$headline, $videoId, $channel, $image]);

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

// Create ad group ad.
$adGroupAd = new AdGroupAd();
$adGroupAd->setAdGroupId($adGroupId);
$adGroupAd->setAd($youtubeAd);
// Optional: Set additional settings.
$adGroupAd->setStatus(AdGroupAdStatus::PAUSED);


// 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()
  );
}

error msg:

Fatal error: Uncaught Google\AdsApi\AdWords\v201710\cm\ApiException: [
AdError.INVALID_YOUTUBE_DISPLAY_URL @ operations[0].operand.ad.displayUrl, 
OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ operations
[0].operand.ad; trigger:'DISPLAY', AdError.EMPTY_FIELD @ operations[0].
operand.ad.templateElements[0].fields[1].fieldMedia; trigger:'', 
AdError.EMPTY_FIELD @ operations[0].operand.ad.templateElements[0].fields[3
].fieldText; trigger:'', UrlError.INVALID_FINAL_URL @ operations[0].
operand.ad.finalUrls[0]; trigger:'https://www.google.com']

How should I fix it?

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords 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 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/10f06087-7938-402f-b906-981321d6a499%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.