Hello,
I'm trying to upload new ads to existent AdGroups, I'm using the
MediaService to re-use the same images but for some reason I get the
following error when I try to upload an ad using the adToCopyImageFrom
param, and I really can't undestand why....
IdError.NOT_FOUND @ operations[0].operand.ad.adToCopyImageFrom
I extracted the code so it be easier to look at, this is more or less the
code I'm using:
1) I upload the image to the MediaService
2) Get the MediaId
3) Create a new ad and set the adToCopyImageFrom param to the MediaId
*$mediaService = $user->GetService('MediaService', ADWORDS_VERSION);*
*$list = array();*
*$image = new Image();*
*$image->data = MediaUtils::GetBase64Data($IMAGE_SRC);*
*$image->type = 'IMAGE';*
*$list[] = $image;*
*$result = $mediaService->upload($list);*
*$mediaID = $result[0]->mediaId;*
*$ad = new ImageAd();*
*$ad->url = $AD_URL;*
*$ad->displayUrl = $DISPLAY_URL;*
*$ad->name = $AD_NAME;*
*$ad->adToCopyImageFrom = $mediaID;*
*$adGroupAd = new AdGroupAd();*
*$adGroupAd->adGroupId = $ADGROUP_ID;*
*$adGroupAd->ad = $ad;*
*$adGroupAd->status = 'ENABLED';*
*$operation = new AdGroupAdOperation();*
*$operation->operand = $**ADGROUP;*
*$operation->operator = 'ADD';*
*$operations[] = $operation;*
*$result = $adGroupAdService->mutate($operations);*
*Error returned:* IdError.NOT_FOUND @
operations[0].operand.ad.adToCopyImageFrom
I printed out the $*operation *object and saw the adToCopyImageFrom is set
to the right MediaId.
I also ran this code to see that the MediaService "holds " the Image, and I
get all the image information with the exact MediaId I used to upload the
ad.
It seems like when I'm uploadng the ad, it doesn't find in the MediaService
the MediaId that I set to adToCopyImageFrom.
Am I missing something here?
*$mediaService = $user->GetService('MediaService', ADWORDS_VERSION);*
*// Create selector.*
*$selector = new Selector();*
*$selector->fields = array('MediaId', 'Width', 'Height', 'MimeType',
'Name', 'Urls', 'CreationTime' , 'FileSize', 'ReferenceId', 'Type',
'SourceUrl');*
*$selector->ordering = array(new OrderBy('MediaId', 'ASCENDING'));*
*// Create predicates.*
*$selector->predicates[] =*
* new Predicate('Type', 'IN', array('IMAGE', 'VIDEO'));*
*// Create paging controls.*
*$selector->paging = new Paging(0,
AdWordsConstants::RECOMMENDED_PAGE_SIZE);*
*do {*
*// Make the get request.*
*$page = $mediaService->get($selector);*
*if (isset($page->entries)) {*
* foreach ($page->entries as $media) {*
* print_r($media);*
* }*
*}*
*$selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE;*
*} while ($page->totalNumEntries > $selector->paging->startIndex);*
Thanks.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.