[PHP Lib] Handling two policy exception in ErrorHandling/HandlePolicyViolationError.php

26 views
Skip to first unread message

Denys Kovalenko

unread,
Aug 20, 2017, 12:42:01 PM8/20/17
to AdWords API Forum
Hi,

In case when two policy exceptions are thrown, for example, in finalURL and Headline1 (which is possible to request via GUI) , the $operation->setExemptionRequests won't allow to add both to $exemptionRequests array, which makes it impossible to create an ExpandedTextAd via API.

Code example is here, https://github.com/googleads/googleads-php-lib/blob/0e091088ae3a0deb2e09927042bcc4a8372625a2/examples/AdWords/v201708/ErrorHandling/HandlePolicyViolationError.php#L104 tested on the latest v201708, Release 28.1.0. Previous code versions also didn't work.


I was told that code example in Java works, but I'm unable to make any changes to hardcoded function/methods of a library, to make it working in PHP. 

I would appreciate any help/suggestions.

Thanks.


Peter Oliquino

unread,
Aug 20, 2017, 11:59:22 PM8/20/17
to AdWords API Forum
Hi Denys,

You should be able to send an array of ExemptionRequests regardless of the client library you use. However, to further investigate, could you provide any logs such as the SOAP request and response that my contain an error message? If you haven't enabled SOAP logging yet, you may refer to this guide as to how. You may reply using Reply privately to author.

Best regards,
Peter
AdWords API Team

Denys Kovalenko

unread,
Aug 21, 2017, 6:38:19 AM8/21/17
to AdWords API Forum
Hi Peter,

Thank you for your answer. There is no error message as such, to validate the Ad Text the code uses $this->session->setValidateOnly(true); first, then ApiException is caught and code adds exemption to operation by using $operation->setExemptionRequests([new ExemptionRequest($error->getKey())]) but in PHP library it only adds one exception to array, where 2 needed. So next step code executes mutate() with $this->session->setValidateOnly(false); but it will not pass as PolicyViolationError will be thrown.

It it helps I have response object from the library error handling:

Google\AdsApi\AdWords\v201708\cm\PolicyViolationError Object ( [key:protected] => Google\AdsApi\AdWords\v201708\cm\PolicyViolationKey Object ( [policyName:protected] => tobacco [violatingText:protected] => cigarettes ) [externalPolicyName:protected] => Tobacco and Cigarettes [externalPolicyUrl:protected] => [externalPolicyDescription:protected] => Google does not permit the advertisement of tobacco and tobacco-related products. Please see our full policy. [isExemptable:protected] => 1 [violatingParts:protected] => Array ( [0] => Google\AdsApi\AdWords\v201708\cm\PolicyViolationErrorPart Object ( [index:protected] => 0 [length:protected] => 10 ) ) [fieldPath:protected] => operations[0].operand.ad.finalUrls [fieldPathElements:protected] => Array ( [0] => Google\AdsApi\AdWords\v201708\cm\FieldPathElement Object ( [field:protected] => operations [index:protected] => 0 ) [1] => Google\AdsApi\AdWords\v201708\cm\FieldPathElement Object ( [field:protected] => operand [index:protected] => ) [2] => Google\AdsApi\AdWords\v201708\cm\FieldPathElement Object ( [field:protected] => ad [index:protected] => ) [3] => Google\AdsApi\AdWords\v201708\cm\FieldPathElement Object ( [field:protected] => finalUrls [index:protected] => ) ) [trigger:protected] => [errorString:protected] => PolicyViolationError.POLICY_ERROR [ApiErrorType:protected] => PolicyViolationError [parameterMap:Google\AdsApi\AdWords\v201708\cm\ApiError:private] => Array ( [ApiError.Type] => ApiErrorType ) )


I'm unable to use out of the library code as a whole project is deeply integrated with PHP Library methods.

Thanks. 
Reply all
Reply to author
Forward
0 new messages