Bug in googleads-php-lib class \XmlDeserializer

23 views
Skip to first unread message

Sebastian Piskorski

unread,
Dec 23, 2016, 9:21:20 AM12/23/16
to AdWords API Forum
If you run:

(new \XmlDeserializer(\ReportUtilsDelegate::$CLASS_MAP))->ConvertXmlToObject($responseXml);

with following XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><reportDownloadError><ApiError><type>AuthenticationError.OAUTH_TOKEN_INVALID</type><trigger>&lt;null&gt;</trigger><fieldPath></fieldPath></ApiError></reportDownloadError>

which is response from AdWords API endpoint. Then it will throw:

ReflectionException('Porperty  does not exist');

Code is run by default when handling API response other than 200 at ReportUtilsDelegate.php line 164 and crashes at XmlDeserializer.php line 144. 

I'm using API v201605 .
Message has been deleted

Sebastian Piskorski

unread,
Dec 23, 2016, 10:11:28 AM12/23/16
to AdWords API Forum
If I add such line early in the script:

require_once 'Google/Api/Ads/AdWords/Util/v201605/ReportUtilsDelegate.php';

the XML will be parsed properly and I get ReportDownloadException. But if  I only define a version with:

/** @var \AdWordsUser $this->client */
$this->client->GetService('ReportDefinitionService', 'v201605');

and then later

(new \ReportUtils())->DownloadReport($reportDefinition, null, $this->client, $options);

Then I get ReflectionExcetion.

Thanet Knack Praneenararat (AdWords API Team)

unread,
Dec 26, 2016, 1:06:31 AM12/26/16
to AdWords API Forum
Hi Sebastian,

I'm afraid that you might use the utility in a wrong way so you're faced with the issue.
The most likely cause would be that you've done require_once of many classes including those from services, e.g., CampaignService.php, which in turn includes ApiError.
But that ApiError is different from the reporting one in that it doesn't have $type.
Thus, when you call the deserializer, it crashes because it can't find such a member variable.
Please see similar case here.

We're happy to help in this forum, but we would appreciate more if you could ask library-related questions on GitHub, so other users can see as well. :-)
Please let me know if anything is still not clear.

Best,
Thanet, AdWords API Team
Reply all
Reply to author
Forward
0 new messages