googleads / googleads-php-lib

Google Ad Manager SOAP API Client Library for PHP
Apache License 2.0
655 stars 768 forks source link

I've tried every way but can't add an out-of-page size to the lineitem #790

Closed quangduc505104 closed 11 months ago

quangduc505104 commented 11 months ago

I need to push a lineitem up to DFP by API-PHP v202308. The lineitem has many sizes, including both regular and out-of-page sizes. I have tried every way to read every instruction, but I still do not know how to push the out-of-page size up to DFP. Please help me, my code is as follows:

            $creativePlaceholder = new CreativePlaceholder();
            $creativePlaceholder->setSize(new Size(-1, -1, true));
            $creativePlaceholders[] = $creativePlaceholder;

             $creativePlaceholder = new CreativePlaceholder();
             $creativePlaceholder->setSize(new Size(300, 250, false));
             $creativePlaceholders[] = $creativePlaceholder;

            $lineItem->setCreativePlaceholders($creativePlaceholders);

I did the following: I used CreativePlaceholder with out-of-page size I used size -1 x -1 and the parameter behind is true

With regular size I used size 300 x 250 with the parameter behind is false however the error message returned to me is: [ERROR PROCESS CREATE OR UPDATE LINEITEM] Code: 0 - Message: [LineItemError.INVALID_SIZE_FOR_PLATFORM

Where did I go wrong? Please help me

christopherseeley commented 11 months ago

Since this is a product question, the Ad Manager API forum is the better place to ask: https://groups.google.com/g/google-doubleclick-for-publishers-api

Sharing full SOAP logs there would help identify the issue, but if I had to guess without complete logs, your OOP placeholder should be a 1x1 pixel size (not aspect ratio) and you should set creativeSizeType to INTERSTITIAL.

quangduc505104 commented 11 months ago

thanks christopherseeley for all your help with the function. Your advice was spot-on and I was able to get it working perfectly. $creativePlaceholders = [];

            $creativePlaceholder = new CreativePlaceholder();
            $creativePlaceholder->setSize(new Size(1, 1, false));
            $creativePlaceholder->setCreativeSizeType('INTERSTITIAL');
            $creativePlaceholders[] = $creativePlaceholder;

             $creativePlaceholder = new CreativePlaceholder();
             $creativePlaceholder->setSize(new Size(300, 250, false));
             $creativePlaceholders[] = $creativePlaceholder;
            $lineItem->setCreativePlaceholders($creativePlaceholders);

The code is correct as it is. I want to share it so that others who encounter the same issue will know how to fix it. Thank you again.

quangduc505104 commented 11 months ago

I was able to process the lineitem, but when creating the creative I followed the size instructions as in the following API documentation: https://developers.google.com/ad-manager/api/reference/v202308/CreativeService.Size The documentation states that the size for out-of-page must be 1x1, I followed this but the code reports an error: ERROR PROCESS CREATE CREATIVE] Code: 0 - Message: [RequiredSizeError.NOT_ALLOWED @ [0].size; trigger:'1x1-null']

Can you help me with this case?

My processing code:

$customCreative = new CustomCreative(); $size = new Size(); $size->setWidth(1); $size->setHeight(1); $size->setIsAspectRatio(false); $customCreative->setSize($size);

Thankiu so much

christopherseeley commented 11 months ago

This is a general API question, not specific to the PHP library. Can you please post on the API forum with full SOAP request logs? They'll be better able to help you: https://groups.google.com/g/google-doubleclick-for-publishers-api

The issue tracker is for library issues. Thanks!